asoc: upgrade aw88261 driver to v1.9.0.5

Version: 1.9.0.5
Optimize driver initialization timing

Change-Id: I7cbc9e056e3afd0b4dd3471ec4fc718c71f3443b
Signed-off-by: guoyf2 <guoyf2@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2204136
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Zhengming Yao <yaozm1@lenovo.com>
Reviewed-by: Hujun Liao <liaohj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
guoyf2 authored and Gilberto Gambugge committed 2023-06-01 00:35:13 -03:00
1 parent e8b5e9bb14
commit 93396078c5
5 files changed
+176 -109

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@
#include "aw_log.h"
#include "aw_dsp.h"
#define AW882XX_DRIVER_VERSION "v1.9.0.4"
#define AW882XX_DRIVER_VERSION "v1.9.0.5"
#define AW882XX_I2C_NAME "aw882xxacf_smartpa"
#define AW_READ_CHIPID_RETRIES 5 /* 5 times */
+128 -104
View File
@@ -570,6 +570,113 @@ static char *aw_dev_get_prof_name(struct aw_device *aw_dev, int index)
return 0;
}*/
static int aw_dev_get_icalk(struct aw_device *aw_dev, int16_t *icalk)
{
int ret = -1;
unsigned int reg_val = 0;
uint16_t reg_icalk = 0;
uint16_t reg_icalkl = 0;
struct aw_vcalb_desc *desc = &aw_dev->vcalb_desc;
if (desc->icalkl_reg == AW_REG_NONE) {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->icalk_reg, &reg_val);
reg_icalk = (uint16_t)reg_val & (~desc->icalk_reg_mask);
} else {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->icalk_reg, &reg_val);
reg_icalk = (uint16_t)reg_val & (~desc->icalk_reg_mask);
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->icalkl_reg, &reg_val);
reg_icalkl = (uint16_t)reg_val & (~desc->icalkl_reg_mask);
if (aw_dev->efuse_check == AW_EF_OR_CHECK)
reg_icalk = (reg_icalk >> desc->icalk_shift) | (reg_icalkl >> desc->icalkl_shift);
else
reg_icalk = (reg_icalk >> desc->icalk_shift) & (reg_icalkl >> desc->icalkl_shift);
}
if (reg_icalk & (~desc->icalk_sign_mask))
reg_icalk = reg_icalk | (~desc->icalk_neg_mask);
*icalk = (int16_t)reg_icalk;
return ret;
}
static int aw_dev_get_vcalk(struct aw_device *aw_dev, int16_t *vcalk)
{
int ret = -1;
unsigned int reg_val = 0;
uint16_t reg_vcalk = 0;
uint16_t reg_vcalkl = 0;
struct aw_vcalb_desc *desc = &aw_dev->vcalb_desc;
if (desc->vcalkl_reg == AW_REG_NONE) {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->vcalk_reg, &reg_val);
reg_vcalk = (uint16_t)reg_val & (~desc->vcalk_reg_mask);
} else {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->vcalk_reg, &reg_val);
reg_vcalk = (uint16_t)reg_val & (~desc->vcalk_reg_mask);
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->vcalkl_reg, &reg_val);
reg_vcalkl = (uint16_t)reg_val & (~desc->vcalkl_reg_mask);
if (aw_dev->efuse_check == AW_EF_OR_CHECK)
reg_vcalk = (reg_vcalk >> desc->vcalk_shift) | (reg_vcalkl >> desc->vcalkl_shift);
else
reg_vcalk = (reg_vcalk >> desc->vcalk_shift) & (reg_vcalkl >> desc->vcalkl_shift);
}
if (reg_vcalk & (~desc->vcalk_sign_mask))
reg_vcalk = reg_vcalk | (~desc->vcalk_neg_mask);
*vcalk = (int16_t)reg_vcalk;
return ret;
}
static int aw_dev_set_vcalb(struct aw_device *aw_dev)
{
int ret = -1;
unsigned int reg_val;
int vcalb;
int icalk;
int vcalk;
int16_t icalk_val = 0;
int16_t vcalk_val = 0;
struct aw_vcalb_desc *desc = &aw_dev->vcalb_desc;
if (desc->icalk_reg == AW_REG_NONE || desc->vcalb_reg == AW_REG_NONE) {
aw_dev_info(aw_dev->dev, "REG None!");
return 0;
}
ret = aw_dev_get_icalk(aw_dev, &icalk_val);
if (ret < 0)
return ret;
ret = aw_dev_get_vcalk(aw_dev, &vcalk_val);
if (ret < 0)
return ret;
icalk = desc->cabl_base_value + desc->icalk_value_factor * icalk_val;
vcalk = desc->cabl_base_value + desc->vcalk_value_factor * vcalk_val;
if (!vcalk) {
aw_dev_err(aw_dev->dev, "vcalk is 0");
return -EINVAL;
}
vcalb = desc->vcal_factor * icalk / vcalk;
reg_val = (unsigned int)vcalb;
aw_dev_info(aw_dev->dev, "icalk=%d, vcalk=%d, vcalb=%d, reg_val=0x%04x",
icalk, vcalk, vcalb, reg_val);
ret = aw_dev->ops.aw_i2c_write(aw_dev, desc->vcalb_reg, reg_val);
aw_dev_info(aw_dev->dev, "done");
return ret;
}
/*pwd enable update reg*/
static int aw_dev_reg_fw_update(struct aw_device *aw_dev)
{
@@ -579,6 +686,7 @@ static int aw_dev_reg_fw_update(struct aw_device *aw_dev)
unsigned int read_val;
int ret = -1;
unsigned int init_volume = 0;
unsigned int efcheck_val = 0;
struct aw_int_desc *int_desc = &aw_dev->int_desc;
struct aw_profctrl_desc *profctrl_desc = &aw_dev->profctrl_desc;
struct aw_bstctrl_desc *bstctrl_desc = &aw_dev->bstctrl_desc;
@@ -655,6 +763,16 @@ static int aw_dev_reg_fw_update(struct aw_device *aw_dev)
reg_val |= read_val;
}
if (reg_addr == aw_dev->efcheck_desc.reg) {
efcheck_val = reg_val & (~aw_dev->efcheck_desc.mask);
if (efcheck_val == aw_dev->efcheck_desc.or_val)
aw_dev->efuse_check = AW_EF_OR_CHECK;
else
aw_dev->efuse_check = AW_EF_AND_CHECK;
aw_dev_info(aw_dev->dev, "efuse check: %d", aw_dev->efuse_check);
}
if (reg_addr == aw_dev->vcalb_desc.vcalb_reg)
continue;
@@ -667,6 +785,12 @@ static int aw_dev_reg_fw_update(struct aw_device *aw_dev)
break;
}
ret = aw_dev_set_vcalb(aw_dev);
if (ret < 0) {
aw_dev_err(aw_dev->dev, "can't set vcalb");
return ret;
}
aw_dev->ops.aw_get_volume(aw_dev, &init_volume);
aw_dev->volume_desc.init_volume = init_volume;
@@ -789,104 +913,6 @@ static void aw_dev_mute(struct aw_device *aw_dev, bool mute)
aw_dev_info(aw_dev->dev, "done");
}
static int aw_dev_get_icalk(struct aw_device *aw_dev, int16_t *icalk)
{
int ret = -1;
unsigned int reg_val = 0;
uint16_t reg_icalk = 0;
uint16_t reg_icalkl = 0;
struct aw_vcalb_desc *desc = &aw_dev->vcalb_desc;
if (desc->icalkl_reg == AW_REG_NONE) {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->icalk_reg, &reg_val);
reg_icalk = (uint16_t)reg_val & (~desc->icalk_reg_mask);
} else {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->icalk_reg, &reg_val);
reg_icalk = (uint16_t)reg_val & (~desc->icalk_reg_mask);
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->icalkl_reg, &reg_val);
reg_icalkl = (uint16_t)reg_val & (~desc->icalkl_reg_mask);
reg_icalk = (reg_icalk >> desc->icalk_shift) | (reg_icalkl >> desc->icalkl_shift);
}
if (reg_icalk & (~desc->icalk_sign_mask))
reg_icalk = reg_icalk | (~desc->icalk_neg_mask);
*icalk = (int16_t)reg_icalk;
return ret;
}
static int aw_dev_get_vcalk(struct aw_device *aw_dev, int16_t *vcalk)
{
int ret = -1;
unsigned int reg_val = 0;
uint16_t reg_vcalk = 0;
uint16_t reg_vcalkl = 0;
struct aw_vcalb_desc *desc = &aw_dev->vcalb_desc;
if (desc->vcalkl_reg == AW_REG_NONE) {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->vcalk_reg, &reg_val);
reg_vcalk = (uint16_t)reg_val & (~desc->vcalk_reg_mask);
} else {
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->vcalk_reg, &reg_val);
reg_vcalk = (uint16_t)reg_val & (~desc->vcalk_reg_mask);
ret = aw_dev->ops.aw_i2c_read(aw_dev, desc->vcalkl_reg, &reg_val);
reg_vcalkl = (uint16_t)reg_val & (~desc->vcalkl_reg_mask);
reg_vcalk = (reg_vcalk >> desc->vcalk_shift) | (reg_vcalkl >> desc->vcalkl_shift);
}
if (reg_vcalk & (~desc->vcalk_sign_mask))
reg_vcalk = reg_vcalk | (~desc->vcalk_neg_mask);
*vcalk = (int16_t)reg_vcalk;
return ret;
}
static int aw_dev_set_vcalb(struct aw_device *aw_dev)
{
int ret = -1;
unsigned int reg_val;
int vcalb;
int icalk;
int vcalk;
int16_t icalk_val = 0;
int16_t vcalk_val = 0;
struct aw_vcalb_desc *desc = &aw_dev->vcalb_desc;
if (desc->icalk_reg == AW_REG_NONE || desc->vcalb_reg == AW_REG_NONE) {
aw_dev_info(aw_dev->dev, "REG None!");
return 0;
}
ret = aw_dev_get_icalk(aw_dev, &icalk_val);
if (ret < 0)
return ret;
ret = aw_dev_get_vcalk(aw_dev, &vcalk_val);
if (ret < 0)
return ret;
icalk = desc->cabl_base_value + desc->icalk_value_factor * icalk_val;
vcalk = desc->cabl_base_value + desc->vcalk_value_factor * vcalk_val;
if (!vcalk) {
aw_dev_err(aw_dev->dev, "vcalk is 0");
return -EINVAL;
}
vcalb = desc->vcal_factor * icalk / vcalk;
reg_val = (unsigned int)vcalb;
aw_dev_info(aw_dev->dev, "icalk=%d, vcalk=%d, vcalb=%d, reg_val=0x%04x",
icalk, vcalk, vcalb, reg_val);
ret = aw_dev->ops.aw_i2c_write(aw_dev, desc->vcalb_reg, reg_val);
aw_dev_info(aw_dev->dev, "done");
return ret;
}
int aw_dev_get_int_status(struct aw_device *aw_dev, uint16_t *int_status)
{
@@ -1186,8 +1212,6 @@ int aw_device_irq_reinit(struct aw_device *aw_dev)
if (ret < 0)
return ret;
/*update vcalb*/
aw_dev_set_vcalb(aw_dev);
return 0;
}
@@ -1217,10 +1241,10 @@ int aw_device_init(struct aw_device *aw_dev, struct aw_container *aw_cfg)
if (ret < 0)
return ret;
ret = aw_dev_set_vcalb(aw_dev);
if (ret < 0) {
aw_dev_err(aw_dev->dev, "can't set vcalb");
return ret;
if (aw_dev->ops.aw_frcset_check) {
ret = aw_dev->ops.aw_frcset_check(aw_dev);
if (ret)
return ret;
}
aw_dev->status = AW_DEV_PW_ON;
+16
View File
@@ -28,6 +28,12 @@ enum {
AW_DEV_TYPE_NONE = 1,
};
enum {
AW_EF_AND_CHECK = 0,
AW_EF_OR_CHECK,
};
enum {
AW_DEV_CH_PRI_L = 0,
AW_DEV_CH_PRI_R = 1,
@@ -68,6 +74,7 @@ struct aw_device_ops {
void (*aw_set_algo)(struct aw_device *aw_dev);
unsigned int (*aw_get_irq_type)(struct aw_device *aw_dev, unsigned int value);
void (*aw_reg_force_set)(struct aw_device *aw_dev);
int (*aw_frcset_check)(struct aw_device *aw_dev);
};
struct aw_int_desc {
@@ -195,12 +202,20 @@ struct aw_container {
uint8_t data[];
};
struct aw_efcheck_desc {
unsigned int reg;
unsigned int mask;
unsigned int and_val;
unsigned int or_val;
};
struct aw_device {
int index;
int status;
int bstcfg_enable;
int frcset_en;
int bop_en;
int efuse_check;
unsigned int mute_st;
unsigned int amppd_st;
@@ -238,6 +253,7 @@ struct aw_device {
struct aw_monitor_desc monitor_desc;
struct aw_soft_rst soft_rst;
struct aw_bop_desc bop_desc;
struct aw_efcheck_desc efcheck_desc;
struct aw_device_ops ops;
struct list_head list_node;
};
+20 -4
View File
@@ -311,6 +311,7 @@ static int aw_pid_1852_dev_init(struct aw882xx *aw882xx, int index)
aw_pa->volume_desc.mute_volume = AW_PID_1852_MUTE_VOL;
aw_pa->bop_desc.reg = AW_REG_NONE;
aw_pa->efcheck_desc.reg = AW_REG_NONE;
aw_pa->soft_rst.reg = AW_PID_1852_ID_REG;
aw_pa->soft_rst.reg_value = AW882XX_SOFT_RESET_VALUE;
@@ -595,6 +596,7 @@ static int aw_pid_2013_dev_init(struct aw882xx *aw882xx, int index)
aw_pa->volume_desc.mute_volume = AW_PID_2013_MUTE_VOL;
aw_pa->bop_desc.reg = AW_REG_NONE;
aw_pa->efcheck_desc.reg = AW_REG_NONE;
aw_pa->soft_rst.reg = AW_PID_2013_ID_REG;
aw_pa->soft_rst.reg_value = AW882XX_SOFT_RESET_VALUE;
@@ -851,6 +853,7 @@ static int aw_pid_2032_dev_init(struct aw882xx *aw882xx, int index)
aw_pa->volume_desc.mute_volume = AW_PID_2032_MUTE_VOL;
aw_pa->bop_desc.reg = AW_REG_NONE;
aw_pa->efcheck_desc.reg = AW_REG_NONE;
aw_pa->soft_rst.reg = AW_PID_2032_ID_REG;
aw_pa->soft_rst.reg_value = AW882XX_SOFT_RESET_VALUE;
@@ -1059,6 +1062,7 @@ static int aw_pid_2055_dev_init(struct aw882xx *aw882xx, int index)
aw_pa->cco_mux_desc.bypass_val = AW_PID_2055_CCO_MUX_BYPASS_VALUE;
aw_pa->bop_desc.reg = AW_REG_NONE;
aw_pa->efcheck_desc.reg = AW_REG_NONE;
aw_pa->soft_rst.reg = AW_PID_2055_ID_REG;
aw_pa->soft_rst.reg_value = AW882XX_SOFT_RESET_VALUE;
@@ -1321,6 +1325,7 @@ static int aw_pid_2071_dev_init(struct aw882xx *aw882xx, int index)
aw_pa->volume_desc.mute_volume = AW_PID_2071_MUTE_VOL;
aw_pa->bop_desc.reg = AW_REG_NONE;
aw_pa->efcheck_desc.reg = AW_REG_NONE;
aw_pa->soft_rst.reg = AW_PID_2071_ID_REG;
aw_pa->soft_rst.reg_value = AW882XX_SOFT_RESET_VALUE;
@@ -1462,11 +1467,12 @@ static unsigned int aw_pid_2113_get_irq_type(struct aw_device *aw_dev,
return ret;
}
static void aw_pid_2113_efver_check(struct aw_device *aw_dev)
static int aw_pid_2113_frcset_check(struct aw_device *aw_dev)
{
unsigned int reg_val = 0;
uint16_t temh = 0;
uint16_t teml = 0;
uint16_t tem = 0;
aw_dev->ops.aw_i2c_read(aw_dev,
AW_PID_2113_EFRH3_REG, &reg_val);
@@ -1476,13 +1482,19 @@ static void aw_pid_2113_efver_check(struct aw_device *aw_dev)
AW_PID_2113_EFRL3_REG, &reg_val);
teml = ((uint16_t)reg_val & (~AW_PID_2113_TEML_MASK));
if ((temh | teml) == AW_PID_2113_DEFAULT_CFG)
if (aw_dev->efuse_check == AW_EF_OR_CHECK)
tem = (temh | teml);
else
tem = (temh & teml);
if (tem == AW_PID_2113_DEFAULT_CFG)
aw_dev->frcset_en = AW_FRCSET_ENABLE;
else
aw_dev->frcset_en = AW_FRCSET_DISABLE;
aw_dev_info(aw_dev->dev, "tem is 0x%04x, frcset_en is %d",
(temh | teml), aw_dev->frcset_en);
tem, aw_dev->frcset_en);
return 0;
}
static void aw_pid_2113_reg_force_set(struct aw_device *aw_dev)
@@ -1556,6 +1568,7 @@ static int aw_pid_2113_dev_init(struct aw882xx *aw882xx, int index)
aw_pa->ops.aw_get_reg_num = aw_pid_2113_get_reg_num;
aw_pa->ops.aw_get_irq_type = aw_pid_2113_get_irq_type;
aw_pa->ops.aw_reg_force_set = aw_pid_2113_reg_force_set;
aw_pa->ops.aw_frcset_check = aw_pid_2113_frcset_check;
aw_pa->int_desc.mask_reg = AW_PID_2113_SYSINTM_REG;
aw_pa->int_desc.mask_default = AW_PID_2113_SYSINTM_DEFAULT;
@@ -1640,7 +1653,10 @@ static int aw_pid_2113_dev_init(struct aw882xx *aw882xx, int index)
AW_PID_2113_INIT_CHECK_VALUE);
usleep_range(AW_3000_US, AW_3000_US +10);
aw_pid_2113_efver_check(aw_pa);
aw_pa->efcheck_desc.reg = AW_PID_2113_DBGCTRL_REG;
aw_pa->efcheck_desc.mask = AW_PID_2113_EF_DBMD_MASK;
aw_pa->efcheck_desc.and_val = AW_PID_2113_AND_VALUE;
aw_pa->efcheck_desc.or_val = AW_PID_2113_OR_VALUE;
ret = aw_device_probe(aw_pa);
+11
View File
@@ -2270,6 +2270,17 @@ const unsigned char aw_pid_2113_reg_access[AW_PID_2113_REG_MAX] = {
/* detail information of registers end */
/********************************************
* Efdbmd
*******************************************/
#define AW_PID_2113_EF_DBMD_MASK (0xfff7)
#define AW_PID_2113_AND_VALUE (0x0000)
#define AW_PID_2113_OR_VALUE (0x0008)
/********************************************
* Volume Coefficient
*******************************************/