As a part of our solution we want to sample audio from I2S microphone. For that purpouse our breakout board have ESAI_SDI0, ESAI_SCKT and ESAI_FST wired out. I have created below device tree so i see soundcard in ALSA listing.
Device Tree
#include "vf610-colibri-eval-v3.dts"
&iomuxc {
vf610-colibri {
pinctrl_gpio_bl_on: gpio_bl_on {
fsl,pins = <
VF610_PAD_PTB19__GPIO_41 0x30
>;
};
// Pin/pad definitions are in vf610-pinfunc.h in the same dir. as this file
// Output only pins - not needed for our use case
// VF610_PAD_PTC2__ESAI_SDO0 0x30d2
// VF610_PAD_PTC3__ESAI_SDO1 0x30d2
esai_pins: esai_pins {
fsl,pins = <
VF610_PAD_PTC0__ESAI_SCKT 0x31C3
VF610_PAD_PTC1__ESAI_FST 0x31C3
VF610_PAD_PTC4__ESAI_SDO2 0x0041
VF610_PAD_PTC5__ESAI_SDO3 0x0041
VF610_PAD_PTC6__ESAI_SDI0 0x0041
VF610_PAD_PTC7__ESAI_SDI1 0x0041
>;
};
};
};
&clks {
clocks = <&sxosc>, <&fxosc>;
clock-names = "sxosc", "fxosc";
};
&aips0 {
esai: esai@40062000 {
compatible = "fsl,vf610-esai";
reg = <0x40062000 0x1000>; // Base address and size of ESAI registers
#sound-dai-cells = <0>;
interrupts = <88 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks VF610_CLK_ESAI>, <&clks VF610_CLK_ESAI>, <&clks VF610_CLK_ESAI>;
clock-names = "core", "extal", "fsys";
assigned-clocks = <&clks VF610_CLK_PLL4>, <&clks VF610_CLK_PLL4_MAIN_DIV>, <&clks VF610_CLK_ESAI_SEL>, <&clks VF610_CLK_ESAI_DIV>, <&clks VF610_CLK_ESAI>;
assigned-clock-parents = <&clks VF610_CLK_PLL4_BYPASS_SRC>, <&clks VF610_CLK_PLL4_AUDIO>, <&clks VF610_CLK_PLL4_MAIN_DIV>, <&clks VF610_CLK_ESAI_EN>, <&clks VF610_CLK_ESAI_DIV>;
assigned-clock-rates = <768000000>, <48000000>, <0>, <12000000>, <0>;
dmas = <&edma0 0 30>, <&edma0 0 31>;
dma-names = "rx", "tx";
fsl,fifo-depth = <128>;
fsl,esai-rx-channels = <4>;
fsl,esai-tx-channels = <2>;
// fsl,esai-synchronous;
pinctrl-names = "default";
pinctrl-0 = <&esai_pins>;
status = "okay";
};
};
/ {
sph0645: mic-codec {
compatible = "linux,snd-soc-dummy";
#sound-dai-cells = <0>;
status = "okay";
};
pure-digital-sound {
compatible = "simple-audio-card";
simple-audio-card,name = "ESAI-Multi-Channel";
status = "okay";
simple-audio-card,dai-link@0 {
format = "i2s";
bitclock-master = <&esai>;
frame-master = <&esai>;
// This is pristine hacking. 48 kHz * 1024 = audio_ext_clk.clock-frequency.
// Really just a hack to trigger the code that registers sound card for input.
mclk-fs = <128>;
cpu {
sound-dai = <&esai>;
system-clock-frequency = <6000000>;
dai-tdm-slot-num = <2>; // Number of slots
dai-tdm-slot-width = <32>; // Width in bits per slot
//dai-tdm-slot-rx-mask = <1 1 1 1 0 0>;
};
codec {
sound-dai = <&sph0645>;
};
};
};
};
However when i start recording using
arecord -v -D hw:1,0 -c 2 -f S24_LE -r 46875 -d 5 test.wav
it both ends with error
arecord -v -D hw:1,0 -c 2 -f S24_LE -r 46875 -d 5 test.wav
[ 1713.779730] fsl-esai-dai 40062000.esai: Startup: syncx=0
Recording WAVE 't[ 1713.786470] fsl-esai-dai 40062000.esai: SYSCLK clk_id=2 freq=6000000 dir=1
est.wav' : Signed[ 1713.794171] fsl-esai-dai 40062000.esai: HWP slot_width=32 params_rate=46875 slots=2
24 bit Little En[ 1713.803342] fsl-esai-dai 40062000.esai: BCLK ratio=2 hck_rate=6000000 freq=3000000 tx=0
dian, Rate 46875 [ 1713.812834] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_xCR(tx)=220 channels=2
Hz, Stereo
[ 1713.821634] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_xFCR(tx)=24
[ 1713.829056] fsl-esai-dai 40062000.esai: HWP[ub] mask=7ff3e val=27f04
[ 1713.835458] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_xCR(tx)=220 mask=7c00 val=7c00
[ 1713.843499] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_PRRC
[ 1713.849311] fsl-esai-dai 40062000.esai: HWP[ub] REG_ESAI_PCRC
[ 1713.855197] fsl-esai-dai 40062000.esai: HWP return
Hardware PCM card[ 1713.881667] fsl-esai-dai 40062000.esai: Trigger: tx=0 channels=2 pins=1 cmd=1
[ 1713.889006] fsl-esai-dai 40062000.esai: Trigger[START]: REG_ESAI_xFCR(tx)=24 REG_ESAI_xCR(tx)=220 ESAI_xCR_TE(pins)=1 ESAI_xCR_RE(pins)=1
1 'ESAI-Multi-Channel' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S24_LE
subformat : STD
channels : 2
rate : 46875
exact rate : 46875 (46875/1)
msbits : 32
buffer_size : 29295
period_size : 5859
period_time : 124992
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 5859
period_event : 0
start_threshold : 1
stop_threshold : 29295
silence_threshold: 0
silence_size : 0
boundary : 1919877120
appl_ptr : 0
hw_ptr : 0
arecord: pcm_read[ 1723.895948] fsl-esai-dai 40062000.esai: Trigger: tx=0 channels=2 pins=1 cmd=0
:2096: read error: Input/output error
and no clock can be detected on either pin (verified by osciloscope).
I have added bunch of log messages to verify what is being written into ESAI registries but majority looks okay.
I even had to tweak the simple-audio-card and the dummy codec to even proceeed to recording as calls for clock setup was not called at all.
One of the problematic point is also the actual crystal clock rate in combination with HW limitations because there is no combination of multiplication and division so 24 MHz cannot be converted to 48 kHz * 64bit/sample. That explains the wierd sample rate in recording so it fits into possible clock rates.
The question
What do I miss so the clocks arent routed to ESAI pins?
Is the ESAI even suported on Toradex colibri VF61?
Additional Info
We have a very sleek linux installation so the below tdx-info is a bit incomplete.
Software summary
------------------------------------------------------------
Bootloader: U-Boot
Kernel version: 4.4.73-2.7.3 #21 2017-06-01
Kernel command line: rw fsl_lpuart.nodma=1 clk_ignore_unused initcall_blacklist=sram_init console=ttyLP0,115200n8 mtdparts=vf610_nfc:128k(vf-bcb)ro,1408k(u-boot)ro,512k(u-boot-env),-(ubi) ubi.mtd=ubi root=ubi0:rootfs-a rootfstype=ubifs ubi.fm_autoconvert=1 rauc.slot=a
Distro name: NAME=PTXdist
Distro version: VERSION_ID="2017.06.0"
Distro variant: -
Hostname: jalud-ptx
------------------------------------------------------------
Hardware info
------------------------------------------------------------
HW model: -
Toradex version:
Serial number: -
Processor arch: armv7l
./tdx-info: line 379: lsblk: not found
Available block devices: -
------------------------------------------------------------
