AnsweredAssumed Answered

关于适配sabresd上的sgtl5000遇到的问题

Question asked by jiang shao on Jan 30, 2018
Latest reply on Apr 12, 2018 by jiang shao

各位尊敬的FAE

 

我在适配客户的sabresd上的sgtl5000时,遇到了问题,需要您的帮助。
Android为4.2.2,cpu是imx6dl。

 

sgtl5000的管脚
SCLK接i2c2_scl
SDA接i2c2_sda

 

我进行的修改如下:
/kernel_imx/sound/soc/imx 下的Kconfig里
添加ARCH_MX6

# changed by shao, 2018-01-29, depends add ARCH_MX6
config SND_SOC_IMX_SGTL5000
tristate "SoC Audio support for i.MX boards with sgtl5000"
depends on I2C && (ARCH_MX6 || MACH_MX35_3DS || MACH_MX51_BABBAGE || MACH_MX53_SMD \
|| MACH_MX6Q_SABRELITE || MACH_MX6Q_ARM2)
select SND_SOC_SGTL5000
select SND_MXC_SOC_MX2
help
Say Y if you want to add support for SoC audio on an i.MX board with
a sgtl5000 codec.

 

添加完毕后保存,再执行make xconfig
就能看到sgtl5000了
勾选sgtl5000后保存,退出

 

板文件(board-mx6q_sabresd.c)参考同目录下的board-mx6q_sabrelite.c修改如下:

//added by shao, 2018-01-29, for SGTL5000
static struct platform_device mx6_sabresd_audio_sgtl5000_device = {
.name = "imx-sgtl5000",
};

//added by shao, 2018-01-29, for SGTL5000
static struct mxc_audio_platform_data mx6_sabresd_sgtl5000_audio_data;

//added by shao, 2018-01-29, for SGTL5000
static int mxc_sabresd_sgtl5000_init(void)
{
struct clk *clko;
struct clk *new_parent;
int rate;

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_sgtl5000_audio_data.sysclk = rate;
clk_set_rate(clko, rate);
clk_enable(clko);
return 0;
}

//added by shao, 2018-01-29, for SGTL5000
static struct mxc_audio_platform_data mx6_sabresd_sgtl5000_audio_data = {
.ssi_num = 1,
.src_port = 2,
.ext_port = 4,
.init = mxc_sabresd_sgtl5000_init,
.hp_gpio = -1,
};

static struct i2c_board_info mxc_i2c1_board_info[] __initdata = {
{
//changed by shao, 2018-01-29, for SGTL5000
//I2C_BOARD_INFO("ak4642", 0x13),
I2C_BOARD_INFO("sgtl5000", 0x0a),

},


//added by shao, 2018-01-30, for SGTL5000, begin
static struct regulator_consumer_supply sgtl5000_sabresd_consumer_vdda = {
.supply = "VDDA",
//.dev_name = "0-000a",
.dev_name = "1-000a",
};

static struct regulator_consumer_supply sgtl5000_sabresd_consumer_vddio = {
.supply = "VDDIO",
//.dev_name = "0-000a",
.dev_name = "1-000a",
};

static struct regulator_consumer_supply sgtl5000_sabresd_consumer_vddd = {
.supply = "VDDD",
//.dev_name = "0-000a",
.dev_name = "1-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 = 2500000,
.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,
.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,
},
};
//added by shao, 2018-01-30, for SGTL5000, end

static int __init imx6q_init_audio(void)
{
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 {
//changed by shao, 2018-01-30, for SGTL5000
//platform_device_register(&sabresd_vwm8962_reg_devices);
//platform_device_register(&sabresd_vak4642_reg_devices);
//mxc_register_device(&fsi_ak4642_device,&ak4642_data);
//mxc_register_device(&mx6_sabresd_audio_wm8962_device,
// &wm8962_data);
mxc_register_device(&mx6_sabresd_audio_sgtl5000_device,
&mx6_sabresd_sgtl5000_audio_data);

imx6q_add_imx_ssi(1, &mx6_sabresd_ssi_pdata);

//mxc_wm8962_init();
//changed by shao, 2018-01-30, for SGTL5000
//mxc_ak4642_init();
platform_device_register(&sgtl5000_sabresd_vdda_reg_devices);
platform_device_register(&sgtl5000_sabresd_vddio_reg_devices);
platform_device_register(&sgtl5000_sabresd_vddd_reg_devices);
}

return 0;
}

if (board_is_mx6_reva()) {
strcpy(mxc_i2c0_board_info[0].type, "wm8958");
mxc_i2c0_board_info[0].platform_data = &wm8958_config_data;
} else {
//strcpy(mxc_i2c0_board_info[0].type, "wm8962");
//mxc_i2c0_board_info[0].platform_data = &wm8962_config_data;

//changed by shao, 2018-01-30, for SGTL5000
//strcpy(mxc_i2c1_board_info[0].type, "ak4642");
//mxc_i2c1_board_info[0].platform_data = &ak4642_config_data;
}


https://community.nxp.com/thread/379269
下载得到
config_sgtl5000.h
tinyalsa_hal.c

 

将config_sgtl5000.h拷贝到/hardware/imx/alsa

 

参考tinyalsa_hal.c,修改/hardware/imx/alsa下的tinyalsa_hal.c如下:

//added by shao, 2018-01-30, for SGTL5000
#include "config_sgtl5000.h"

/*"null_card" must be in the end of this array*/
struct audio_card *audio_card_list[SUPPORT_CARD_NUM] = {
//changed by shao, 2018-01-30, for SGTL5000
&sgtl5000_card,
//&wm8960_card,
&wm8958_card,
&wm8962_card,
&hdmi_card,
&usbaudio_card,
&spdif_card,
//&cs42888_card,
&null_card,
};

 

确认/kernel_imx/sound/soc/imx下的imx-sgtl5000.c
里面已经是1-000a,无需修改

static struct snd_soc_dai_link imx_sgtl5000_dai[] = {
{
.name = "HiFi",
.stream_name = "HiFi",
.codec_dai_name = "sgtl5000",
.codec_name = "sgtl5000.1-000a",
.cpu_dai_name = "imx-ssi.1",
.platform_name = "imx-pcm-audio.1",
.init = imx_3stack_sgtl5000_init,
.ops = &imx_sgtl5000_hifi_ops,
},
};

static int __init imx_sgtl5000_init(void)
{
int ret;

ret = platform_driver_register(&imx_sgtl5000_audio_driver);
if (ret)
return -ENOMEM;

if (machine_is_mx35_3ds() || machine_is_mx6q_sabrelite())
imx_sgtl5000_dai[0].codec_name = "sgtl5000.0-000a";
else
imx_sgtl5000_dai[0].codec_name = "sgtl5000.1-000a";


然而烧写后,重复出现类似

<<-GTP-ERROR->> I2C Read: 0x814E, 10 bytes failed, errcode: -5! Process reset.
<<-GTP-INFO->> Guitar reset
<<-GTP-ERROR->> I2C transfer error. errno:-5

的错误,具体请看附件

 

请问还有什么不妥的地方吗?

Attachments

Outcomes