Hi All,
We have a DRA7xx based customised board (reference VAYU Board) and
I'm working to adapt an OS linux version based on GLSDK-7.0.2 (kernel 3.14) on our custum board.
When I try to play an audio wav file with alsa's player aplay, I get the following errors:
bash-3.2# aplay Alarm_Classic.wav
Playing WAVE 'Alarm_Classic.wav' :
Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
After few seconds.....
pcm_write:1939: write error: Input/output error
-bash-3.2# dmesg
ALSA sound/core/pcm_lib.c:1957 playback write error (DMA or IRQ trouble?)
My registered sound card is:
-bash-3.2# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: DRA7xxGHMIOS [DRA7xx-GHMIOS], device 0: AIC31XX tlv320aic31xx-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
Playing the same file audio on the same board with OS Android 6AJ.1.3 ( kernel 3.8.13) ,
it sounds good with no error so I'm sure that is not a hardware problem.
Basically my configurations in kernel 3.14 are these:
DTS:
dac_pins: pinmux_dac_pins {
pinctrl-single,pins = <
0x298 0x00005 /* xref_clk1.mcasp2.atl_clk1 PIN OUTPUT */ /*MCLK pin TLV320DAC3100 */
0x2B8 0x1000E /* mcasp1_axr1.gpio5_3 PIN OUTPUT */ /*CODEC_RESET~ pin TLV320DAC3100 */
0x2F4 0x00180 /* mcasp2_aclkx.mcasp2_aclkx PIN OUTPUT */ /*BCLK pin TLV320DAC3100 */
0x2F8 0x00180 /* mcasp2_fsx.mcasp2_fsx PIN OUTPUT */ /*WCLK pin TLV320DAC3100 */
0x30C 0x00180 /* mcasp2_axr2.mcasp2_axr2 PIN OUTPUT */ /*DIN pin TLV320DAC3100 */
>;
};
mcasp2: mcasp@48464000 {
compatible = "ti,dra7-mcasp-audio";
ti,hwmods = "mcasp2";
reg = <0x48464000 0x2000>;
reg-names = "mpu";
interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>, /* AREVT */
<GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>; /* TXEVT */
interrupt-names = "tx", "rx";
dmas = <&sdma_xbar 131>, <&sdma_xbar 130>;
dma-names = "tx", "rx";
clocks = <&mcasp2_ahclkx_mux>;
clock-names = "fck";
status = "disabled";
};
primary_sound: primary_sound {
compatible = "ti,dra7xx-ghmios-snd";
ti,model = "DRA7xx-GHMIOS";
ti,always-on;
ti,audio-codec = <&tlv320dac3100>;
ti,mcasp-controller = <&mcasp2>;
ti,codec-clock-rate = <11289600>;
ti,audio-slots = <2>;
clocks = <&atl_clkin1_ck>;
clock-names = "ti,codec-clock";
ti,audio-mclk-freq = <11289600>;
ti,audio-routing =
"Headphone", "HPL",
"Headphone", "HPR",
"Speaker", "SPK";
};
&atl {
status = "okay";
atl1 {
bws = <DRA7_ATL_WS_MCASP2_FSX>;
aws = <DRA7_ATL_WS_MCASP2_FSX>;
};
};
&mcasp2 {
pinctrl-names = "default";
pinctrl-0 = <&dac_pins>;
fck_parent = "atl_clkin1_ck";
status = "okay";
op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>;
num-serializer = <16>;
/* 16 serializer channel 2 AXR2 0:INACTIVE, 1:TX, 2:RX */
serial-dir = <0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0>;
tx-num-evt = <8>;
rx-num-evt = <8>;
};
&i2c1 {
status = "okay";
clock-frequency = <400000>;
pinctrl-0 = <&i2c1_pins>;
tlv320dac3100: tlv320dac3100@18 {
compatible = "ti,tlv320aic3100";
gpio-reset = <&gpio5 3 1>;
reg = <0x18>;
ai31xx-micbias-vg = <1>; //not used
status = "okay";
// /* Regulators */
AVDD-supply = <&evm_3v3_sw>;
IOVDD-supply = <&evm_3v3_sw>;
DRVDD-supply = <&evm_3v3_sw>;
DVDD-supply = <&aic_dvdd>;
};
};
I used the TLV320DAC3100 codec driver(tlv320aic31xx.c)
and a custom machine driver(dra7xx-ghmios-card.c derivated from dra7xx-jamr3-card.c )
to configure DAI interfaces.
static struct snd_soc_dai_link ghmios_snd_dai = {
/* McASP2 + tlv320dac3100 */
.name = "TLV320AIC3XX",
.stream_name = "AIC31XX",
.ops = &ghmios_snd_ops,
.codec_dai_name = "tlv320aic31xx-hifi",
.init = ghmios_snd_init,
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS |
SND_SOC_DAIFMT_IB_NF,
};
Following an extract from dra7xx-ghmios-card.c hw_params function
****************************************************************
/* McASP driver requires inverted frame for I2S */
snd_soc_dai_set_fmt(cpu_dai, fmt | SND_SOC_DAIFMT_NB_IF);
/* Set McASP BCLK divider (clkid = 1) */
snd_soc_dai_set_clkdiv(cpu_dai, 1,card_data->mclk_freq / bclk_freq);
/* Set McASP sysclk from AHCLKX sourced from ATL */
snd_soc_dai_set_sysclk(cpu_dai, 0, card_data->mclk_freq,SND_SOC_CLOCK_IN);
snd_soc_dai_set_fmt(codec_dai, fmt | SND_SOC_DAIFMT_NB_NF);
******************************************************************
With these configurations I 've got these clocks:
MCLK = 11289600 HZ
BCLK = 1411200 HZ
I inserted some printk in davinci_mcasp driver for debugging the issue and I saw that:
mcasp_start_tx: McASP2.DAVINCI_MCASP_TXSTAT_REG = 12c (XDATA Transmit data ready flag is always 1)
mcasp_start_tx: MCASP_XRSRCTL_REG(2) = 19
FROM TRM the XRDY BIT(4) is 0x1: The transmit buffer (MCASP_TXBUFn) is empty and needs to
be written before the start of the next time slot or a transmit underrun occurs.
From logs I see the following DMA croossbar setting for MCASP2:
[ 2.857927] davinci-mcasp 48464000.mcasp: ASoC: Registered component '48464000.mcasp'
[ 2.865842] ti-dma-crossbar 4a002b78.dma-crossbar: Mapping XBAR131 to DMA7
[ 2.872760] omap-dma-engine 4a056000.dma-controller: allocating channel 7 for 8
[ 2.880114] __dma_request_channel: success (dma1chan7)
[ 2.885329] ti-dma-crossbar 4a002b78.dma-crossbar: Mapping XBAR130 to DMA8
[ 2.892244] omap-dma-engine 4a056000.dma-controller: allocating channel 8 for 9
[ 2.899598] __dma_request_channel: success (dma1chan8)
But the SDMA interrupts are not triggering and I' got the error
"ALSA sound/core/pcm_lib.c:1957 playback write error (DMA or IRQ trouble?)" .
My questions are:
What could be wrong or missing in DMA CROSSBAR mappings?
What cpu register must be checked to be sure that all DMA mapping for MCASP2 are correct?
Is it also necessary modify u-boot for macsp dma crossbar settings?
Thanks,
Antonio