在imx6q上移植了SGTL5000, 但是启动时提示
ALSA device list:
No soundcards found.
声卡挂在i2c2上的地址0xa上,代码如下:
static struct i2c_board_info mxc_i2c2_board_info[] __initdata = {
#ifdef CONFIG_SND_SOC_SGTL5000
{
I2C_BOARD_INFO("sgtl5000", 0x0a),
},
#endif
使用i2c工具可以看到设备
root@freescale /$ i2cdetect -r -y 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- UU -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
board-mx6q_sabresd.c 设备注册关键代码如下 :
#ifdef CONFIG_SND_SOC_SGTL5000
static struct regulator_consumer_supply sgtl5000_sabresd_consumer_vdda = {
.supply = "VDDA",
.dev_name = "0-000a",
};
static struct regulator_consumer_supply sgtl5000_sabresd_consumer_vddio = {
.supply = "VDDIO",
.dev_name = "0-000a",
};
static struct regulator_consumer_supply sgtl5000_sabresd_consumer_vddd = {
.supply = "VDDD",
.dev_name = "0-000a",
};
static struct regulator_init_data sgtl5000_sabresd_vdda_reg_initdata = {
.num_consumer_supplies = 1,
.consumer_supplies = &sgtl5000_sabresd_consumer_vdda,
};
static struct regulator_init_data sgtl5000_sabresd_vddio_reg_initdata = {
.num_consumer_supplies = 1,
.consumer_supplies = &sgtl5000_sabresd_consumer_vddio,
};
static struct regulator_init_data sgtl5000_sabresd_vddd_reg_initdata = {
.num_consumer_supplies = 1,
.consumer_supplies = &sgtl5000_sabresd_consumer_vddd,
};
static struct fixed_voltage_config sgtl5000_sabresd_vdda_reg_config = {
.supply_name = "VDDA",
.microvolts = 3300000,
.gpio = -1,
.init_data = &sgtl5000_sabresd_vdda_reg_initdata,
};
static struct fixed_voltage_config sgtl5000_sabresd_vddio_reg_config = {
.supply_name = "VDDIO",
.microvolts = 3300000,
.gpio = -1,
.init_data = &sgtl5000_sabresd_vddio_reg_initdata,
};
static struct fixed_voltage_config sgtl5000_sabresd_vddd_reg_config = {
.supply_name = "VDDD",
.microvolts =0,//modify huangyangyou from 0
.gpio = -1,
.init_data = &sgtl5000_sabresd_vddd_reg_initdata,
};
static struct platform_device sgtl5000_sabresd_vdda_reg_devices = {
.name = "reg-fixed-voltage",
.id = 0,
.dev = {
.platform_data = &sgtl5000_sabresd_vdda_reg_config,
},
};
static struct platform_device sgtl5000_sabresd_vddio_reg_devices = {
.name = "reg-fixed-voltage",
.id = 1,
.dev = {
.platform_data = &sgtl5000_sabresd_vddio_reg_config,
},
};
static struct platform_device sgtl5000_sabresd_vddd_reg_devices = {
.name = "reg-fixed-voltage",
.id = 2,
.dev = {
.platform_data = &sgtl5000_sabresd_vddd_reg_config,
},
};
static struct platform_device mx6_sabresd_audio_device = {
.name = "imx-sgtl5000",
};
static struct mxc_audio_platform_data mx6_sabresd_audio_data;
static int mx6_sabresd_sgtl5000_init(void)
{
struct clk *clko;
struct clk *new_parent;
int rate;
pr_info("\n\r start mx6_sabresd_sgtl5000_init ");
clko = clk_get(NULL, "clko_clk");
if (IS_ERR(clko)) {
pr_err("can't get CLKO clock.\n");
return PTR_ERR(clko);
}
new_parent = clk_get(NULL, "ahb");
if (!IS_ERR(new_parent)) {
clk_set_parent(clko, new_parent);
clk_put(new_parent);
}
rate = clk_round_rate(clko, 16000000);
if (rate < 8000000 || rate > 27000000) {
pr_err("Error:SGTL5000 mclk freq %d out of range!\n", rate);
clk_put(clko);
return -1;
}
mx6_sabresd_audio_data.sysclk = rate;
clk_set_rate(clko, rate);
clk_enable(clko);
pr_info("\n\r end mx6_sabresd_sgtl5000_init ");
return 0;
}
static struct mxc_audio_platform_data mx6_sabresd_audio_data = {
.ssi_num = 1,
.src_port = 2,
.ext_port = 4,
.init = mx6_sabresd_sgtl5000_init,
.hp_gpio = -1,
};
#endif /* CONFIG_SND_SOC_SGTL5000 */
static int __init imx6q_init_audio(void)
{
int ret=0;
pr_info("\n\r\n\r start imx6q_init_audio \n\r");
#ifdef CONFIG_SND_SOC_SGTL5000
pr_info("\n\r\n\r start initiall audio \n\r");
gpio_request(SABRESD_AUDIO_AMPLIFIER_PWR, "audio_pwr");
gpio_direction_output(SABRESD_AUDIO_AMPLIFIER_PWR, 1);
gpio_set_value(SABRESD_AUDIO_AMPLIFIER_PWR, 1);
gpio_request(SABRESD_AUDIO_CHIP_PWR, "audio_pwr");
gpio_direction_output(SABRESD_AUDIO_CHIP_PWR, 1);
gpio_set_value(SABRESD_AUDIO_CHIP_PWR, 1);
ret=mxc_register_device(&mx6_sabresd_audio_device,
&mx6_sabresd_audio_data);
pr_info("\n\r %s:%d %d\n\r\n\r",__func__, __LINE__,ret);
ret=imx6q_add_imx_ssi(1, &mx6_sabresd_ssi_pdata);
pr_info("\n\r %s:%d %d\n\r\n\r",__func__, __LINE__,ret);
ret=platform_device_register(&sgtl5000_sabresd_vdda_reg_devices);
pr_info("\n\r %s:%d %d\n\r\n\r",__func__, __LINE__,ret);
ret=platform_device_register(&sgtl5000_sabresd_vddio_reg_devices);
pr_info("\n\r %s:%d %d\n\r\n\r",__func__, __LINE__,ret);
ret=platform_device_register(&sgtl5000_sabresd_vddd_reg_devices);
pr_info("\n\r %s:%d %d\n\r\n\r",__func__, __LINE__,ret);
pr_info("\n\r end initiall audio \n\r\n\r");
return 0;
#else
if (board_is_mx6_reva()) {
mxc_register_device(&mx6_sabresd_audio_wm8958_device,
&wm8958_data);
imx6q_add_imx_ssi(1, &mx6_sabresd_ssi_pdata);
mxc_wm8958_init();
} else
{
if(audio_codec == CODEC_WM8962)
{
platform_device_register(&sabresd_vwm8962_reg_devices);
mxc_register_device(&mx6_sabresd_audio_wm8962_device,
&wm8962_data);
imx6q_add_imx_ssi(1, &mx6_sabresd_ssi_pdata);
mxc_wm8962_init();
}else
{
mxc_register_device(&mx6_sabresd_audio_wm8960_device,
&wm8960_data);
imx6q_add_imx_ssi(1, &mx6_sabresd_ssi_pdata);
mxc_wm8960_init();
}
}//end if
return 0;
#endif
}
static void __init mx6_sabresd_board_init(void)
{
.
.
.
imx6q_add_imx_i2c(0, &mx6q_sabresd_i2c_data);
imx6q_add_imx_i2c(1, &mx6q_sabresd_i2c_data);
imx6q_add_imx_i2c(2, &mx6q_sabresd_i2c_data);
platform_add_devices(hsi2c_gpio_devices, ARRAY_SIZE(hsi2c_gpio_devices));
if (cpu_is_mx6dl())
imx6q_add_imx_i2c(3, &mx6q_sabresd_i2c_data);
i2c_register_board_info(0, mxc_i2c0_board_info,
ARRAY_SIZE(mxc_i2c0_board_info));
i2c_register_board_info(1, mxc_i2c1_board_info,
ARRAY_SIZE(mxc_i2c1_board_info));
//if(screen_type0==SCREEN_LCD)
pr_info("\n\r\n\r start i2c_register_board_info mxc_i2c2_board_info %s\n\r",mxc_i2c2_board_info[0].type);
ret= i2c_register_board_info(2, mxc_i2c2_board_info,
ARRAY_SIZE(mxc_i2c2_board_info));
pr_info("\n\r%s:%d ret=%d\n\r", __func__,__LINE__,ret);
//else if(screen_type1==SCREEN_LVDS||screen_type0==SCREEN_LVDS)
//i2c_register_board_info(2, mxc_i2c2_board_info1,
// ARRAY_SIZE(mxc_i2c2_board_info1));
//else
//i2c_register_board_info(2, mxc_i2c2_board_info2,
// ARRAY_SIZE(mxc_i2c2_board_info2));
i2c_register_board_info(3, mxc_i2c3_board_info,
ARRAY_SIZE(mxc_i2c3_board_info));
.
.
.
.
imx6q_add_hdmi_soc();
imx6q_add_hdmi_soc_dai();
pr_info("\n\rbefore imx6q_init_audio() ");
#ifdef CONFIG_SND_SOC_SGTL5000
pr_info("\n\rbefore 1 imx6q_init_audio() ");
imx6q_init_audio();
#endif
pr_info("\n\r after imx6q_init_audio() ");
}
查看状态
root@freescale /$ cat /proc/asound/cards
--- no soundcards ---
root@freescale /$
root@freescale /$ cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
5 /dev/tty
5 /dev/console
5 /dev/ptmx
7 vcs
10 misc
13 input
14 sound
29 fb
66 fsl-usb2-otg
81 video4linux
89 i2c
90 mtd
108 ppp
116 alsa
128 ptm
136 pts
180 usb
188 ttyUSB
189 usb_device
199 galcore
207 ttymxc
216 rfcomm
250 hidraw
251 mxc_asrc
252 mxc_vpu
253 mxc_ipu
254 rtc
root@freescale /$ ls -l /sys/bus/i2c/devices/
lrwxrwxrwx 1 root root 0 Jan 1 00:00 0-001c -> ../../../devices/platform/imx-i2c.0/i2c-0/0-001c
lrwxrwxrwx 1 root root 0 Jan 1 00:00 1-0004 -> ../../../devices/platform/imx-i2c.1/i2c-1/1-0004
lrwxrwxrwx 1 root root 0 Jan 1 00:00 1-0008 -> ../../../devices/platform/imx-i2c.1/i2c-1/1-0008
lrwxrwxrwx 1 root root 0 Jan 1 00:00 1-0038 -> ../../../devices/platform/imx-i2c.1/i2c-1/1-0038
lrwxrwxrwx 1 root root 0 Jan 1 00:00 1-0040 -> ../../../devices/platform/imx-i2c.1/i2c-1/1-0040
lrwxrwxrwx 1 root root 0 Jan 1 00:00 2-000a -> ../../../devices/platform/imx-i2c.2/i2c-2/2-000a
lrwxrwxrwx 1 root root 0 Jan 1 00:00 i2c-0 -> ../../../devices/platform/imx-i2c.0/i2c-0
lrwxrwxrwx 1 root root 0 Jan 1 00:00 i2c-1 -> ../../../devices/platform/imx-i2c.1/i2c-1
lrwxrwxrwx 1 root root 0 Jan 1 00:00 i2c-2 -> ../../../devices/platform/imx-i2c.2/i2c-2
lrwxrwxrwx 1 root root 0 Jan 1 00:00 i2c-3 -> ../../../devices/platform/i2c-gpio.3/i2c-3
root@freescale /$ ls -l /sys/bus/i2c/drivers
drwxr-xr-x 2 root root 0 Jan 1 00:00 Goodix-TS-gt911
drwxr-xr-x 2 root root 0 Jan 1 00:00 Goodix-TS-gt928
drwxr-xr-x 2 root root 0 Jan 1 00:00 cs42888
drwxr-xr-x 2 root root 0 Jan 1 00:00 dummy
drwxr-xr-x 2 root root 0 Jan 1 00:00 ft5x0x_ts
drwxr-xr-x 2 root root 0 Jan 1 00:00 isl29023
drwxr-xr-x 2 root root 0 Jan 1 00:00 mag3110
drwxr-xr-x 2 root root 0 Jan 1 00:00 max17135
drwxr-xr-x 2 root root 0 Jan 1 00:00 mc_pfuze
drwxr-xr-x 2 root root 0 Jan 1 00:00 mma8451
drwxr-xr-x 2 root root 0 Jan 1 00:00 mxc_dvi
drwxr-xr-x 2 root root 0 Jan 1 00:00 mxc_hdmi_i2c
drwxr-xr-x 2 root root 0 Jan 1 00:00 pca953x
drwxr-xr-x 2 root root 0 Jan 1 00:00 rtc-rx8010
drwxr-xr-x 2 root root 0 Jan 1 00:00 sgtl5000
drwxr-xr-x 2 root root 0 Jan 1 00:00 wm8960-codec
drwxr-xr-x 2 root root 0 Jan 1 00:00 wm8962
drwxr-xr-x 2 root root 0 Jan 1 00:00 wm8994
root@freescale /$ ls /dev/snd/
seq timer
root@freescale /$
我在驱动加了打印发现:sgtl5000_i2c_probe 被调用了, 但是sgtl5000_probe没有被调用,请问这个问题如何定位,谢谢!
附件为日志
Solved! Go to Solution.
Hi, Steven,
could you share your board-mx6q_xxx.c file and schematic?
(In addition, I found you are using version of L 3.0.35 kernel, which is very old version, why not use the newer one?)
Have a nice day!
BR,
Weidong
Hi Steven,
SGTL5000 is supported by iMX6Q Sabre Lite board, it's BSP is board-mx6q_sabrelite.c in Linux 3.0.35 kernel, in the file you will find how to use SGTL5000 audio codec.
Refer to it, please!
Have a nice day!
BR,
Weidong
代码是从board-mx6q_sabrelite.c 拷贝过来的, 参考了board-mx6q_sabrelite.c里面的代码,和board-mx6q_sabrelite.c的代码做对比,没发现有什么问题, 但是在mx6q_sabresd 上 就是不工作,请问如何进一步调查,谢谢!
Hi, Steven,
could you share your board-mx6q_xxx.c file and schematic?
(In addition, I found you are using version of L 3.0.35 kernel, which is very old version, why not use the newer one?)
Have a nice day!
BR,
Weidong
hello Wigros:
thank you for you reply, I have fixed this issue, the sgtl5000 is hanged on i2c2, so the device name should modify. Now, I can see the sound card on my board.