Dear all,
I am working on a custom board based on an AM3352 and I have adapted a driver for the AIC32x4 codec.
At the moment the codec seems to be initialized correctly, I can see the audio driver card registered but when I play some audio I can not get the sound. The HW architecture is the same as in the AM3358EVMSK but I use the mcasp0 instead of mcasp1. This means that the master clock is taken from the CPU clock and the bit and frame clock should be generated by the mcasp.
What I see with the oscilloscope is that the mclk (24MHz) is available but the bclk (mcasp0_aclkx pin A13 ZCZ) and the frame clock (mcasp0_FSX) does not output.
According to the Sitara Linux Audio DAC Example these signals should be output as far as the mcasp has been configured.
I have set them on the DTS:
mcasp0_pins: mcasp0_pins { pinctrl-single,pins = < 0x198 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr0.mcasp0_axr0 D12*/ 0x1A8 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr1.mcasp0_axr1 D13*/ 0x194 (PIN_OUTPUT_PULLUP | MUX_MODE0) /* mcasp0_fsx.mcasp0_fsx B13*/ 0x190 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx.mcasp0_aclkx A13*/ 0x1ac (PIN_OUTPUT_PULLUP | MUX_MODE7) /* mcasp0_ahclkx.GPIO3_21 A14*/ >; }; [....] &mcasp0 { pinctrl-names = "default", "sleep"; pinctrl-0 = <&mcasp0_pins>; pinctrl-1 = <&mcasp0_pins_sleep>; status = "okay"; op-mode = <0>; /* MCASP_IIS_MODE */ tdm-slots = <2>; /* 4 serializers */ serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */ 1 2 0 0 >; tx-num-evt = <32>; rx-num-evt = <32>; }; [....] sound { compatible = "ti,ermes-audio"; ti,model = "AM335x-EVMSK"; ti,audio-codec = <&tlv320aic32x4>; ti,mcasp-controller = <&mcasp0>; ti,codec-clock-rate = <24000000>; ti,audio-routing = "Line In", "IN1_L", "Line In", "IN1_R", "Line In", "IN2_L", "Line In", "IN2_R", "Line In", "IN3_L", "Line In", "IN3_R", "Line Out", "LOR", "Line Out", "LOL", "Headphone Jack", "HPL", "Headphone Jack", "HPR"; };
Then I have modified the davinci-evm.c set_hw_params as follow:
static int ermes_aic32x4_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_card *soc_card = rtd->card; struct platform_device *pdev = to_platform_device(soc_card->dev); int ret = 0; u32 dai_format; //TODO channels 2 e se mono? unsigned int bclk_freq = evm_get_bclk(params, 2); unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) snd_soc_card_get_drvdata(soc_card))->sysclk; printk("davinci-evm.c aic32x4 ermes: 1. start set HW params\n"); ret = snd_soc_dai_set_clkdiv(cpu_dai, 1, sysclk/bclk_freq); if (ret < 0) { dev_err(&pdev->dev, "can't set CPU DAI clock divider %d\n", ret); return ret; } dai_format = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM; /* set codec DAI configuration */ snd_soc_dai_set_fmt(codec_dai, dai_format); /* set cpu DAI configuration */ snd_soc_dai_set_fmt(cpu_dai, dai_format); ret = snd_soc_dai_set_sysclk(codec_dai, 0, 24000000, SND_SOC_CLOCK_OUT); if (ret) { pr_err("%s: failed setting codec sysclk\n", __func__); return ret; } /* set the CPU system clock */ printk("davinci-evm.c aic32x4 ermes: 2. setup CPU system clock\n"); printk("davinci-evm.c aic32x4 ermes: sysclk=%d, bclk_freq=%d\n", sysclk, bclk_freq); ret = snd_soc_dai_set_sysclk(cpu_dai, 0, sysclk, SND_SOC_CLOCK_OUT); if (ret) { pr_err("can't set CPU system clock \n"); return ret; } return 0; }
At the moment I can't figure why the bit and frame clock are not generated by the mcasp.
Thank you in advance for the support.