AM437X TAS2552驱动移植





step1:设备树配置
    
MCASP引脚配置:
mcasp1_pins: mcasp1_pins {
pinctrl-single,pins = <
0x108 (PIN_OUTPUT_PULLDOWN | MUX_MODE4)/*D16=mii1_col.mcasp1_axr2= DIN_F_CPU*/
0x10c (PIN_INPUT_PULLDOWN | MUX_MODE4)/*B14=mii1_crs.mcasp1_aclkx=BCLK */
0x110 (PIN_INPUT_PULLDOWN | MUX_MODE4)/*B13=mii1_rxerr.mcasp1_fsx =WCLK*/
0x144 (PIN_INPUT_PULLDOWN | MUX_MODE4)/*A16=rmii1_ref_clk.mcasp1_axr3=DOUT_TO_CPU */
>;
};

&mcasp1 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&mcasp1_pins>;
pinctrl-1 = <&mcasp1_sleep_pins>;


status = "okay";


op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>; 
/* 4 serializers */
 #指定serializer的方向。AM437x的手册中提到每个McASP有16个serializer,但AM437x这款芯片的McAPS只有4个serializer,
 #分别用于AXR0、AXR1、AXR2和ARX3。由于AM437x mcasp1中将AXR2作为发送(输出)、ARX3作为接收(输入)且没有ARX0和ARX1,故设置4个serial-dir为0、0、1、2
serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
0 0 1 2 
>;
tx-num-evt = <32>;
rx-num-evt = <32>;
};




sound {
compatible = "ti,myd-c437x-audio";
ti,model = "AM437x-GP-EVM";
ti,audio-codec = <&tas2552>;
ti,mcasp-controller = <&mcasp1>;
#ti,codec-clock-rate = <22579200>;#设置codec频率,不是MCLK频率  ,(这儿有点疑问!)
ti,codec-clock-rate = <24576000>;
ti,audio-routing =
"Headphone Jack",       "HPLOUT",
"Headphone Jack",       "HPROUT",
"LINE1L",               "Line In",
"LINE1R",               "Line In";
};




tas2552: tas2552@41 {
compatible = "ti,tas2552";
reg = <0x41>;
clocks = <&l4hs_gclk>;
clock-names = "fck";
status="okay";
enable-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>;
/* gpio pin test */
enable-tasled3 = <&gpio2 1 GPIO_ACTIVE_HIGH>;
enable-tasled4 = <&gpio3 1 GPIO_ACTIVE_HIGH>;
enable-tasled5 = <&gpio3 17 GPIO_ACTIVE_HIGH>;
VDDA-supply = <&evm_v3p3>;
VDDIO-supply = <&evm_v3p3>;
VDDD-supply = <&evm_v3p3>;
};


step2:内核配置


Device Drivers  --->  
<*> Sound card support  --->  
<*>   Advanced Linux Sound Architecture  ---> 
<*>   ALSA for SoC audio support  --->                                                           
< >   SoC Audio for the Atmel System-on-Chip                       
<*>   SoC Audio for TI DAVINCI or AM33XX/AM43XX chips                                                   
<*>   SoC Audio for the AM33XX chip based boards                  #如果在调试阶段,可将此编译成模块M,方便调试                                                   
<M>   SoC Audio for the AM43XX and TLV320AIC3111 based board  
<*>   SoC Audio for the Texas Instruments OMAP chips

step3:修改davinci-evm函数


static int evm_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_codec *codec = rtd->codec;
struct snd_soc_card *soc_card = codec->card;
int ret = 0;
unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *)
  snd_soc_card_get_drvdata(soc_card))->sysclk;
// 添加下列函数,设置分频比
unsigned int bclk_freq = evm_get_bclk(params); 
ret = snd_soc_dai_set_clkdiv(cpu_dai, 1,sysclk / bclk_freq);
if (ret < 0) {
dev_err(soc_card->dev, "can't set CPU DAI clock divider %d\n",
ret);
}  
 ..........
}


static struct snd_soc_dai_link enno_dai_tas2552 = {
.name      = "tas2552",
.stream_name = "tas2552-hifi",
.codec_dai_name = "tas2552-hifi",  /*这个名字要与驱动中 结构体snd_soc_dai_driver的成员name 保持一致*/
.ops        = &evm_ops,
.dai_fmt    = (/*SND_SOC_DAIFMT_CBM_CFM no sound*/SND_SOC_DAIFMT_I2S|SND_SOC_DAIFMT_CBS_CFS | 
  SND_SOC_DAIFMT_NB_IF),
};


//添加到声卡 注册表中
static const struct of_device_id davinci_evm_dt_ids[] = {
......
/* For myd-c437x, MYiR */
{
.compatible = "ti,myd-c437x-audio",
.data = &enno_dai_tas2552,
},
{ /* sentinel */ }
};






其他设置:


设置音量
/usr/bin/mplayer -af volume=-1 ./player/cd.mp3 












参考文章:

AM335x(TQ335x)学习笔记——WM8960声卡驱动移植:http://blog.csdn.net/girlkoo/article/details/42042555

数字音频接口基础知识:http://www.wangdali.net/i2s/

linux音频子系统:http://blog.csdn.net/DroidPhone/article/category/1118446

时钟关系:http://www.cnblogs.com/SFREEDOM/archive/2010/08/04/1791868.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值