开发环境:
内核版本:linux4.14.12
开发板:itopimx6ull
sound {
compatible = "simple-audio-card";
//simple-audio-card,name = "mx6ul-wm8960";
simple-audio-card,name = "MY_WM8960";
simple-audio-card,format = "i2s";//音频数据传输格式
simple-audio-card,mclk-fs = <1536>;//主控供给编解码芯片用的时钟
//fsl,sai-asynchronous;
simple-audio-card,bitclock-master = <&dailink_master>;//产生位时钟的模块
simple-audio-card,frame-master = <&dailink_master>;//产生帧时钟的模块?
//simple-audio-card,hp-det = <3 0>;
simple-audio-card,hp-det-gpio = <&gpio5 4 GPIO_ACTIVE_LOW>;//耳机插入检测接口
//simple-audio-card,mic-det-gpio = <&gpio5 4 GPIO_ACTIVE_LOW>;//麦克风插入检测接口
simple-audio-card,widgets =
"Microphone", "Mic Jack",//麦克风widgets
//"Line", "Line In",
//"Line", "Line Out",
"Speaker", "Speaker",//外放widgets
"Headphone", "Headphone Jack";//耳机widgets
//其中"HP_L"、"HP_R"、"SPK_LP"、"SPK_LN"、"SPK_RP"、"SPK_RN"、"MICB"、"LINPUT1"
//在codec部分的代码里面找对应控件链路的名字
simple-audio-card,routing =
"Headphone Jack", "HP_L",//耳机左声道routing
"Headphone Jack", "HP_R",//耳机右声道routing
"Speaker", "SPK_LP",//外放routing
"Speaker", "SPK_LN",//外放routing
"Speaker", "SPK_RP",//外放routing
"Speaker", "SPK_RN",//外放routing
"Mic Jack","MICB",//麦克风偏置routing
"LINPUT1", "Mic Jack";//麦克风输入routing
//"LINPUT3", "Mic Jack",
//"RINPUT1", "Mic Jack",
//"RINPUT2", "Mic Jack";
simple-audio-card,cpu {
sound-dai = <&sai2>;//cpu端接口
};
dailink_master: simple-audio-card,codec {
sound-dai = <&codec>;//编解码芯片端接口
clocks = <&clks IMX6UL_CLK_SAI2>;
};
};
&sai2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai2>;
assigned-clocks = <&clks IMX6UL_CLK_SAI2_SEL>,
<&clks IMX6UL_CLK_SAI2>;
assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;
//assigned-clock-rates = <0>, <12288000>;
assigned-clock-rates = <0>, <24000000>;
fsl,sai-mclk-direction-output;//mclk由sai2提供
status = "okay";
};
codec: wm8960@1a {
#sound-dai-cells = <0>;
compatible = "wlf,wm8960";
reg = <0x1a>;
wlf,shared-lrclk;
};
//在codec部分,wm8960_i2c_probe中加入代码,打开对应的设置
//add by mhq
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, 3<<5, 3<<5);
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 3<<2, 3<<2);
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL1, 3, 3);
//gpio1
regmap_update_bits(wm8960->regmap, WM8960_IFACE2, 1<<6, 1<<6);
regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 7<<4, 3<<4);
//headphone volmue
regmap_update_bits(wm8960->regmap, WM8960_LOUT1, 0x7f, 90);
regmap_update_bits(wm8960->regmap, WM8960_ROUT1, 0x7f, 90);
//headphone vol
regmap_update_bits(wm8960->regmap, WM8960_LOUTMIX, 0x100, 0x100);
regmap_update_bits(wm8960->regmap, WM8960_ROUTMIX, 0x100, 0x100);
//add end