Lines Matching +full:i2c +full:- +full:crc +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0-only
3 // aw88399.c -- ALSA SoC AW88399 codec support
12 #include <linux/i2c.h>
34 ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); in aw_dev_dsp_write_16bit()
36 dev_err(aw_dev->dev, "%s write addr error, ret=%d", __func__, ret); in aw_dev_dsp_write_16bit()
40 ret = regmap_write(aw_dev->regmap, AW88399_DSPMDAT_REG, (u16)dsp_data); in aw_dev_dsp_write_16bit()
42 dev_err(aw_dev->dev, "%s write data error, ret=%d", __func__, ret); in aw_dev_dsp_write_16bit()
55 ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); in aw_dev_dsp_write_32bit()
57 dev_err(aw_dev->dev, "%s write addr error, ret=%d", __func__, ret); in aw_dev_dsp_write_32bit()
62 ret = regmap_write(aw_dev->regmap, AW88399_DSPMDAT_REG, temp_data); in aw_dev_dsp_write_32bit()
64 dev_err(aw_dev->dev, "%s write datal error, ret=%d", __func__, ret); in aw_dev_dsp_write_32bit()
69 ret = regmap_write(aw_dev->regmap, AW88399_DSPMDAT_REG, temp_data); in aw_dev_dsp_write_32bit()
71 dev_err(aw_dev->dev, "%s write datah error, ret=%d", __func__, ret); in aw_dev_dsp_write_32bit()
82 mutex_lock(&aw_dev->dsp_lock); in aw_dev_dsp_write()
87 dev_err(aw_dev->dev, "write dsp_addr[0x%x] 16-bit dsp_data[0x%x] failed", in aw_dev_dsp_write()
93 dev_err(aw_dev->dev, "write dsp_addr[0x%x] 32-bit dsp_data[0x%x] failed", in aw_dev_dsp_write()
97 dev_err(aw_dev->dev, "data type[%d] unsupported", data_type); in aw_dev_dsp_write()
98 ret = -EINVAL; in aw_dev_dsp_write()
103 if (regmap_read(aw_dev->regmap, 0x00, ®_value)) in aw_dev_dsp_write()
104 dev_err(aw_dev->dev, "%s fail to clear chip state. Err=%d\n", __func__, ret); in aw_dev_dsp_write()
105 mutex_unlock(&aw_dev->dsp_lock); in aw_dev_dsp_write()
116 ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); in aw_dev_dsp_read_16bit()
118 dev_err(aw_dev->dev, "%s write error, ret=%d", __func__, ret); in aw_dev_dsp_read_16bit()
122 ret = regmap_read(aw_dev->regmap, AW88399_DSPMDAT_REG, &temp_data); in aw_dev_dsp_read_16bit()
124 dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); in aw_dev_dsp_read_16bit()
138 ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); in aw_dev_dsp_read_32bit()
140 dev_err(aw_dev->dev, "%s write error, ret=%d", __func__, ret); in aw_dev_dsp_read_32bit()
144 ret = regmap_read(aw_dev->regmap, AW88399_DSPMDAT_REG, &temp_data); in aw_dev_dsp_read_32bit()
146 dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); in aw_dev_dsp_read_32bit()
151 ret = regmap_read(aw_dev->regmap, AW88399_DSPMDAT_REG, &temp_data); in aw_dev_dsp_read_32bit()
153 dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); in aw_dev_dsp_read_32bit()
167 mutex_lock(&aw_dev->dsp_lock); in aw_dev_dsp_read()
172 dev_err(aw_dev->dev, "read dsp_addr[0x%x] 16-bit dsp_data[0x%x] failed", in aw_dev_dsp_read()
178 dev_err(aw_dev->dev, "read dsp_addr[0x%x] 32r-bit dsp_data[0x%x] failed", in aw_dev_dsp_read()
182 dev_err(aw_dev->dev, "data type[%d] unsupported", data_type); in aw_dev_dsp_read()
183 ret = -EINVAL; in aw_dev_dsp_read()
188 if (regmap_read(aw_dev->regmap, AW88399_ID_REG, ®_value)) in aw_dev_dsp_read()
189 dev_err(aw_dev->dev, "%s fail to clear chip state. ret=%d\n", __func__, ret); in aw_dev_dsp_read()
190 mutex_unlock(&aw_dev->dsp_lock); in aw_dev_dsp_read()
200 ret = regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw_dev_pwd()
203 ret = regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw_dev_pwd()
207 dev_dbg(aw_dev->dev, "%s failed", __func__); in aw_dev_pwd()
215 ret = regmap_read(aw_dev->regmap, AW88399_SYSINT_REG, ®_val); in aw_dev_get_int_status()
217 dev_err(aw_dev->dev, "read interrupt reg fail, ret=%d", ret); in aw_dev_get_int_status()
221 dev_dbg(aw_dev->dev, "read interrupt reg=0x%04x", *int_status); in aw_dev_get_int_status()
233 dev_dbg(aw_dev->dev, "int status(%d) is not cleaned.\n", int_status); in aw_dev_clear_int_status()
241 ret = regmap_read(aw_dev->regmap, AW88399_SYSST_REG, ®_val); in aw_dev_get_iis_status()
245 dev_err(aw_dev->dev, "check pll lock fail, reg_val:0x%04x", reg_val); in aw_dev_get_iis_status()
246 return -EINVAL; in aw_dev_get_iis_status()
259 dev_err(aw_dev->dev, "mode1 iis signal check error"); in aw_dev_check_mode1_pll()
266 return -EPERM; in aw_dev_check_mode1_pll()
274 ret = regmap_read(aw_dev->regmap, AW88399_PLLCTRL2_REG, ®_val); in aw_dev_check_mode2_pll()
280 dev_dbg(aw_dev->dev, "CCO_MUX is already divider"); in aw_dev_check_mode2_pll()
281 return -EPERM; in aw_dev_check_mode2_pll()
285 ret = regmap_update_bits(aw_dev->regmap, AW88399_PLLCTRL2_REG, in aw_dev_check_mode2_pll()
293 dev_err(aw_dev->dev, "mode2 iis signal check error"); in aw_dev_check_mode2_pll()
301 regmap_update_bits(aw_dev->regmap, AW88399_PLLCTRL2_REG, in aw_dev_check_mode2_pll()
308 dev_err(aw_dev->dev, "mode2 switch to mode1, iis signal check error"); in aw_dev_check_mode2_pll()
325 dev_dbg(aw_dev->dev, "mode1 check iis failed try switch to mode2 check"); in aw_dev_check_syspll()
328 dev_err(aw_dev->dev, "mode2 check iis failed"); in aw_dev_check_syspll()
342 ret = regmap_read(aw_dev->regmap, AW88399_PWMCTRL3_REG, ®_val); in aw_dev_check_sysst()
352 ret = regmap_read(aw_dev->regmap, AW88399_SYSST_REG, ®_val); in aw_dev_check_sysst()
357 dev_err(aw_dev->dev, "check sysst fail, cnt=%d, reg_val=0x%04x, check:0x%x", in aw_dev_check_sysst()
365 return -EPERM; in aw_dev_check_sysst()
373 ret = regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw_dev_amppd()
376 ret = regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw_dev_amppd()
380 dev_dbg(aw_dev->dev, "%s failed", __func__); in aw_dev_amppd()
388 ret = regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw_dev_dsp_enable()
391 ret = regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw_dev_dsp_enable()
395 dev_dbg(aw_dev->dev, "%s failed\n", __func__); in aw_dev_dsp_enable()
401 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_dev_get_icalk()
405 ret = regmap_read(aw_dev->regmap, AW88399_EFRH4_REG, ®_val); in aw88399_dev_get_icalk()
410 ret = regmap_read(aw_dev->regmap, AW88399_EFRL4_REG, ®_val); in aw88399_dev_get_icalk()
415 if (aw88399->check_val == AW_EF_AND_CHECK) in aw88399_dev_get_icalk()
430 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_dev_get_vcalk()
434 ret = regmap_read(aw_dev->regmap, AW88399_EFRH3_REG, ®_val); in aw88399_dev_get_vcalk()
440 ret = regmap_read(aw_dev->regmap, AW88399_EFRL3_REG, ®_val); in aw88399_dev_get_vcalk()
446 if (aw88399->check_val == AW_EF_AND_CHECK) in aw88399_dev_get_vcalk()
461 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_dev_get_internal_vcalk()
465 ret = regmap_read(aw_dev->regmap, AW88399_EFRH2_REG, ®_val); in aw88399_dev_get_internal_vcalk()
470 ret = regmap_read(aw_dev->regmap, AW88399_EFRL2_REG, ®_val); in aw88399_dev_get_internal_vcalk()
475 if (aw88399->check_val == AW_EF_AND_CHECK) in aw88399_dev_get_internal_vcalk()
492 struct aw_device *aw_dev = aw88399->aw_pa; in aw_dev_set_vcalb()
499 ret = regmap_read(aw_dev->regmap, AW88399_VSNCTRL1_REG, &vsense_value); in aw_dev_set_vcalb()
507 dev_err(aw_dev->dev, "get icalk failed\n"); in aw_dev_set_vcalb()
518 ical_k / vcal_k * aw88399->vcalb_init_val; in aw_dev_set_vcalb()
525 vcal_k * aw88399->vcalb_init_val; in aw_dev_set_vcalb()
528 dev_err(aw_dev->dev, "%s: unsupported vsense\n", __func__); in aw_dev_set_vcalb()
529 ret = -EINVAL; in aw_dev_set_vcalb()
538 regmap_write(aw_dev->regmap, AW88399_DSPVCALB_REG, reg_val); in aw_dev_set_vcalb()
551 if ((aw_dev->cali_desc.cali_re >= AW88399_CALI_RE_MAX) || in aw_dev_update_cali_re()
552 (aw_dev->cali_desc.cali_re <= AW88399_CALI_RE_MIN)) in aw_dev_update_cali_re()
553 return -EINVAL; in aw_dev_update_cali_re()
555 cali_re = AW88399_SHOW_RE_TO_DSP_RE((aw_dev->cali_desc.cali_re + in aw_dev_update_cali_re()
556 aw_dev->cali_desc.ra), AW88399_DSP_RE_SHIFT); in aw_dev_update_cali_re()
561 ret = regmap_write(aw_dev->regmap, AW88399_ACR1_REG, re_hbits); in aw_dev_update_cali_re()
563 dev_err(aw_dev->dev, "set cali re error"); in aw_dev_update_cali_re()
567 ret = regmap_write(aw_dev->regmap, AW88399_ACR2_REG, re_lbits); in aw_dev_update_cali_re()
569 dev_err(aw_dev->dev, "set cali re error"); in aw_dev_update_cali_re()
581 fw_len_val = ((aw_dev->dsp_fw_len / AW_FW_ADDR_LEN) - 1) + AW88399_CRC_FW_BASE_ADDR; in aw_dev_fw_crc_check()
584 ret = regmap_update_bits(aw_dev->regmap, AW88399_CRCCTRL_REG, in aw_dev_fw_crc_check()
588 /* enable fw crc check */ in aw_dev_fw_crc_check()
589 ret = regmap_update_bits(aw_dev->regmap, AW88399_CRCCTRL_REG, in aw_dev_fw_crc_check()
594 /* read crc check result */ in aw_dev_fw_crc_check()
595 regmap_read(aw_dev->regmap, AW88399_HAGCST_REG, ®_val); in aw_dev_fw_crc_check()
601 /* disable fw crc check */ in aw_dev_fw_crc_check()
602 ret = regmap_update_bits(aw_dev->regmap, AW88399_CRCCTRL_REG, in aw_dev_fw_crc_check()
608 dev_err(aw_dev->dev, "%s failed, check_val 0x%x != 0x%x", in aw_dev_fw_crc_check()
610 ret = -EINVAL; in aw_dev_fw_crc_check()
623 cfg_len_val = ((aw_dev->dsp_cfg_len / AW_FW_ADDR_LEN) - 1) + AW88399_CRC_CFG_BASE_ADDR; in aw_dev_cfg_crc_check()
626 ret = regmap_update_bits(aw_dev->regmap, AW88399_CRCCTRL_REG, in aw_dev_cfg_crc_check()
631 /* enable cfg crc check */ in aw_dev_cfg_crc_check()
632 ret = regmap_update_bits(aw_dev->regmap, AW88399_CRCCTRL_REG, in aw_dev_cfg_crc_check()
639 /* read crc check result */ in aw_dev_cfg_crc_check()
640 ret = regmap_read(aw_dev->regmap, AW88399_HAGCST_REG, ®_val); in aw_dev_cfg_crc_check()
646 /* disable cfg crc check */ in aw_dev_cfg_crc_check()
647 ret = regmap_update_bits(aw_dev->regmap, AW88399_CRCCTRL_REG, in aw_dev_cfg_crc_check()
653 dev_err(aw_dev->dev, "crc_check failed, check val 0x%x != 0x%x", in aw_dev_cfg_crc_check()
655 ret = -EINVAL; in aw_dev_cfg_crc_check()
663 struct aw_device *aw_dev = aw88399->aw_pa; in aw_dev_hw_crc_check()
666 ret = regmap_update_bits(aw_dev->regmap, AW88399_I2SCFG1_REG, in aw_dev_hw_crc_check()
673 dev_err(aw_dev->dev, "fw_crc_check failed\n"); in aw_dev_hw_crc_check()
679 dev_err(aw_dev->dev, "cfg_crc_check failed\n"); in aw_dev_hw_crc_check()
683 ret = regmap_write(aw_dev->regmap, AW88399_CRCCTRL_REG, aw88399->crc_init_val); in aw_dev_hw_crc_check()
687 ret = regmap_update_bits(aw_dev->regmap, AW88399_I2SCFG1_REG, in aw_dev_hw_crc_check()
693 regmap_update_bits(aw_dev->regmap, AW88399_I2SCFG1_REG, in aw_dev_hw_crc_check()
703 ret = regmap_update_bits(aw_dev->regmap, AW88399_I2SCTRL3_REG, in aw_dev_i2s_tx_enable()
706 ret = regmap_update_bits(aw_dev->regmap, AW88399_I2SCFG1_REG, in aw_dev_i2s_tx_enable()
710 dev_dbg(aw_dev->dev, "%s failed", __func__); in aw_dev_i2s_tx_enable()
718 ret = regmap_read(aw_dev->regmap, AW88399_WDT_REG, ®_val); in aw_dev_get_dsp_status()
722 return -EPERM; in aw_dev_get_dsp_status()
731 switch (aw_dev->dsp_cfg) { in aw_dev_dsp_check()
733 dev_dbg(aw_dev->dev, "dsp bypass"); in aw_dev_dsp_check()
743 dev_err(aw_dev->dev, "dsp wdt status error=%d", ret); in aw_dev_dsp_check()
749 dev_err(aw_dev->dev, "unknown dsp cfg=%d", aw_dev->dsp_cfg); in aw_dev_dsp_check()
750 ret = -EINVAL; in aw_dev_dsp_check()
759 struct aw_volume_desc *vol_desc = &aw_dev->volume_desc; in aw_dev_set_volume()
764 real_value = min((value + vol_desc->init_volume), (unsigned int)AW88399_MUTE_VOL); in aw_dev_set_volume()
766 ret = regmap_read(aw_dev->regmap, AW88399_SYSCTRL2_REG, ®_value); in aw_dev_set_volume()
770 dev_dbg(aw_dev->dev, "value 0x%x , reg:0x%x", value, real_value); in aw_dev_set_volume()
774 ret = regmap_write(aw_dev->regmap, AW88399_SYSCTRL2_REG, real_value); in aw_dev_set_volume()
781 struct aw_volume_desc *desc = &aw_dev->volume_desc; in aw_dev_fade_in()
782 u16 fade_in_vol = desc->ctl_volume; in aw_dev_fade_in()
783 int fade_step = aw_dev->fade_step; in aw_dev_fade_in()
786 if (fade_step == 0 || aw_dev->fade_in_time == 0) { in aw_dev_fade_in()
791 for (i = AW88399_MUTE_VOL; i >= fade_in_vol; i -= fade_step) { in aw_dev_fade_in()
793 usleep_range(aw_dev->fade_in_time, aw_dev->fade_in_time + 10); in aw_dev_fade_in()
802 struct aw_volume_desc *desc = &aw_dev->volume_desc; in aw_dev_fade_out()
803 int fade_step = aw_dev->fade_step; in aw_dev_fade_out()
806 if (fade_step == 0 || aw_dev->fade_out_time == 0) { in aw_dev_fade_out()
811 for (i = desc->ctl_volume; i <= AW88399_MUTE_VOL; i += fade_step) { in aw_dev_fade_out()
813 usleep_range(aw_dev->fade_out_time, aw_dev->fade_out_time + 10); in aw_dev_fade_out()
818 usleep_range(aw_dev->fade_out_time, aw_dev->fade_out_time + 10); in aw_dev_fade_out()
826 regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw88399_dev_mute()
829 regmap_update_bits(aw_dev->regmap, AW88399_SYSCTRL_REG, in aw88399_dev_mute()
837 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_dev_set_dither()
840 regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG, in aw88399_dev_set_dither()
843 regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG, in aw88399_dev_set_dither()
849 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_dev_start()
852 if (aw_dev->status == AW88399_DEV_PW_ON) { in aw88399_dev_start()
853 dev_dbg(aw_dev->dev, "already power on"); in aw88399_dev_start()
865 dev_err(aw_dev->dev, "pll check failed cannot start"); in aw88399_dev_start()
876 dev_err(aw_dev->dev, "sysst check failed"); in aw88399_dev_start()
880 if (aw_dev->dsp_cfg == AW88399_DEV_DSP_WORK) { in aw88399_dev_start()
883 dev_err(aw_dev->dev, "dsp crc check failed"); in aw88399_dev_start()
888 aw_dev_update_cali_re(&aw_dev->cali_desc); in aw88399_dev_start()
892 dev_err(aw_dev->dev, "dsp status check failed"); in aw88399_dev_start()
896 dev_dbg(aw_dev->dev, "start pa with dsp bypass"); in aw88399_dev_start()
899 /* enable tx feedback */ in aw88399_dev_start()
902 if (aw88399->dither_st == AW88399_DITHER_EN_ENABLE_VALUE) in aw88399_dev_start()
909 aw_dev->status = AW88399_DEV_PW_ON; in aw88399_dev_start()
921 aw_dev->status = AW88399_DEV_PW_OFF; in aw88399_dev_start()
932 mutex_lock(&aw_dev->dsp_lock); in aw_dev_dsp_update_container()
933 ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, base); in aw_dev_dsp_update_container()
938 tmp_len = min(len - i, AW88399_MAX_RAM_WRITE_BYTE_SIZE); in aw_dev_dsp_update_container()
939 ret = regmap_raw_write(aw_dev->regmap, AW88399_DSPMDAT_REG, in aw_dev_dsp_update_container()
944 mutex_unlock(&aw_dev->dsp_lock); in aw_dev_dsp_update_container()
949 mutex_unlock(&aw_dev->dsp_lock); in aw_dev_dsp_update_container()
963 dev_err(aw_dev->dev, "read ra error"); in aw_dev_get_ra()
967 cali_desc->ra = AW88399_DSP_RE_TO_SHOW_RE(dsp_ra, in aw_dev_get_ra()
978 dev_dbg(aw_dev->dev, "dsp config len:%d", len); in aw_dev_dsp_update_cfg()
981 dev_err(aw_dev->dev, "dsp config data is null or len is 0"); in aw_dev_dsp_update_cfg()
982 return -EINVAL; in aw_dev_dsp_update_cfg()
989 aw_dev->dsp_cfg_len = len; in aw_dev_dsp_update_cfg()
991 ret = aw_dev_get_ra(&aw_dev->cali_desc); in aw_dev_dsp_update_cfg()
1001 dev_dbg(aw_dev->dev, "dsp firmware len:%d", len); in aw_dev_dsp_update_fw()
1004 dev_err(aw_dev->dev, "dsp firmware data is null or len is 0"); in aw_dev_dsp_update_fw()
1005 return -EINVAL; in aw_dev_dsp_update_fw()
1008 aw_dev->dsp_fw_len = len; in aw_dev_dsp_update_fw()
1018 mutex_lock(&aw_dev->dsp_lock); in aw_dev_check_sram()
1022 dev_err(aw_dev->dev, "check dsp rom failed, read[0x%x] != check[0x%x]", in aw_dev_check_sram()
1031 dev_err(aw_dev->dev, "check dsp cfg failed, read[0x%x] != write[0x%x]", in aw_dev_check_sram()
1035 mutex_unlock(&aw_dev->dsp_lock); in aw_dev_check_sram()
1039 mutex_unlock(&aw_dev->dsp_lock); in aw_dev_check_sram()
1040 return -EPERM; in aw_dev_check_sram()
1049 ret = regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG, in aw_dev_select_memclk()
1053 dev_err(aw_dev->dev, "memclk select pll failed"); in aw_dev_select_memclk()
1056 ret = regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG, in aw_dev_select_memclk()
1060 dev_err(aw_dev->dev, "memclk select OSC failed"); in aw_dev_select_memclk()
1063 dev_err(aw_dev->dev, "unknown memclk config, flag=0x%x", flag); in aw_dev_select_memclk()
1070 struct aw_profctrl_desc *profctrl_desc = &aw_dev->profctrl_desc; in aw_dev_get_cur_mode_st()
1074 ret = regmap_read(aw_dev->regmap, AW88399_SYSCTRL_REG, ®_val); in aw_dev_get_cur_mode_st()
1076 dev_dbg(aw_dev->dev, "%s failed", __func__); in aw_dev_get_cur_mode_st()
1080 profctrl_desc->cur_mode = AW88399_RCV_MODE; in aw_dev_get_cur_mode_st()
1082 profctrl_desc->cur_mode = AW88399_NOT_RCV_MODE; in aw_dev_get_cur_mode_st()
1088 struct aw_device *aw_dev = aw88399->aw_pa; in aw_dev_update_reg_container()
1089 struct aw_volume_desc *vol_desc = &aw_dev->volume_desc; in aw_dev_update_reg_container()
1099 dev_err(aw_dev->dev, "data len:%d unsupported", data_len); in aw_dev_update_reg_container()
1100 return -EINVAL; in aw_dev_update_reg_container()
1108 aw88399->vcalb_init_val = reg_val; in aw_dev_update_reg_container()
1114 aw_dev->dsp_cfg = AW88399_DEV_DSP_BYPASS; in aw_dev_update_reg_container()
1116 aw_dev->dsp_cfg = AW88399_DEV_DSP_WORK; in aw_dev_update_reg_container()
1132 aw_dev->volume_desc.init_volume = read_vol; in aw_dev_update_reg_container()
1137 aw88399->check_val = AW_EF_OR_CHECK; in aw_dev_update_reg_container()
1139 aw88399->check_val = AW_EF_AND_CHECK; in aw_dev_update_reg_container()
1141 aw88399->dither_st = reg_val & (~AW88399_DITHER_EN_MASK); in aw_dev_update_reg_container()
1145 aw88399->crc_init_val = reg_val; in aw_dev_update_reg_container()
1147 ret = regmap_write(aw_dev->regmap, reg_addr, reg_val); in aw_dev_update_reg_container()
1157 if (aw_dev->prof_cur != aw_dev->prof_index) in aw_dev_update_reg_container()
1158 vol_desc->ctl_volume = 0; in aw_dev_update_reg_container()
1160 aw_dev_set_volume(aw_dev, vol_desc->ctl_volume); in aw_dev_update_reg_container()
1171 dev_err(aw88399->aw_pa->dev, "reg data is null or len is 0"); in aw_dev_reg_update()
1172 return -EINVAL; in aw_dev_reg_update()
1177 dev_err(aw88399->aw_pa->dev, "reg update failed"); in aw_dev_reg_update()
1184 struct aw_prof_info *prof_info = &aw_dev->prof_info; in aw88399_dev_get_prof_name()
1187 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw88399_dev_get_prof_name()
1188 dev_err(aw_dev->dev, "index[%d] overflow count[%d]", in aw88399_dev_get_prof_name()
1189 index, aw_dev->prof_info.count); in aw88399_dev_get_prof_name()
1190 return -EINVAL; in aw88399_dev_get_prof_name()
1193 prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw88399_dev_get_prof_name()
1195 *prof_name = prof_info->prof_name_list[prof_desc->id]; in aw88399_dev_get_prof_name()
1203 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw88399_dev_get_prof_data()
1204 dev_err(aw_dev->dev, "%s: index[%d] overflow count[%d]\n", in aw88399_dev_get_prof_data()
1205 __func__, index, aw_dev->prof_info.count); in aw88399_dev_get_prof_data()
1206 return -EINVAL; in aw88399_dev_get_prof_data()
1209 *prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw88399_dev_get_prof_data()
1216 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_dev_fw_update()
1222 if ((aw_dev->prof_cur == aw_dev->prof_index) && in aw88399_dev_fw_update()
1224 dev_dbg(aw_dev->dev, "scene no change, not update"); in aw88399_dev_fw_update()
1228 if (aw_dev->fw_status == AW88399_DEV_FW_FAILED) { in aw88399_dev_fw_update()
1229 dev_err(aw_dev->dev, "fw status[%d] error", aw_dev->fw_status); in aw88399_dev_fw_update()
1230 return -EPERM; in aw88399_dev_fw_update()
1233 ret = aw88399_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name); in aw88399_dev_fw_update()
1237 dev_dbg(aw_dev->dev, "start update %s", prof_name); in aw88399_dev_fw_update()
1239 ret = aw88399_dev_get_prof_data(aw_dev, aw_dev->prof_index, &prof_index_desc); in aw88399_dev_fw_update()
1244 sec_desc = prof_index_desc->sec_desc; in aw88399_dev_fw_update()
1248 dev_err(aw_dev->dev, "update reg failed"); in aw88399_dev_fw_update()
1254 if (aw_dev->dsp_cfg == AW88399_DEV_DSP_WORK) in aw88399_dev_fw_update()
1261 dev_err(aw_dev->dev, "check sram failed"); in aw88399_dev_fw_update()
1266 dev_dbg(aw_dev->dev, "fw_ver: [%x]", prof_index_desc->fw_ver); in aw88399_dev_fw_update()
1270 dev_err(aw_dev->dev, "update dsp fw failed"); in aw88399_dev_fw_update()
1279 dev_err(aw_dev->dev, "update dsp cfg failed"); in aw88399_dev_fw_update()
1285 aw_dev->prof_cur = aw_dev->prof_index; in aw88399_dev_fw_update()
1301 dev_err(aw88399->aw_pa->dev, "aw88399 device start failed. retry = %d", i); in aw88399_start_pa()
1304 dev_err(aw88399->aw_pa->dev, "fw update failed"); in aw88399_start_pa()
1308 dev_dbg(aw88399->aw_pa->dev, "start success\n"); in aw88399_start_pa()
1319 mutex_lock(&aw88399->lock); in aw88399_startup_work()
1321 mutex_unlock(&aw88399->lock); in aw88399_startup_work()
1328 if (aw88399->aw_pa->fw_status != AW88399_DEV_FW_OK) in aw88399_start()
1331 if (aw88399->aw_pa->status == AW88399_DEV_PW_ON) in aw88399_start()
1336 dev_err(aw88399->aw_pa->dev, "fw update failed."); in aw88399_start()
1344 &aw88399->start_work, in aw88399_start()
1354 dev_err(aw_dev->dev, "pa stop check fail:0x%04x", reg_val); in aw_dev_check_sysint()
1355 return -EINVAL; in aw_dev_check_sysint()
1364 &aw_dev->prof_info.prof_desc[aw_dev->prof_cur].sec_desc[AW88395_DATA_TYPE_DSP_CFG]; in aw88399_stop()
1366 &aw_dev->prof_info.prof_desc[aw_dev->prof_cur].sec_desc[AW88395_DATA_TYPE_DSP_FW]; in aw88399_stop()
1369 if (aw_dev->status == AW88399_DEV_PW_OFF) { in aw88399_stop()
1370 dev_dbg(aw_dev->dev, "already power off"); in aw88399_stop()
1374 aw_dev->status = AW88399_DEV_PW_OFF; in aw88399_stop()
1390 aw_dev_dsp_update_fw(aw_dev, dsp_fw->data, dsp_fw->len); in aw88399_stop()
1391 aw_dev_dsp_update_cfg(aw_dev, dsp_cfg->data, dsp_cfg->len); in aw88399_stop()
1402 .name = "aw88399-aif",
1431 struct cali_cfg *cali_cfg = &aw_dev->cali_desc.cali_cfg; in aw_cali_svc_get_cali_cfg()
1435 &cali_cfg->data[0], AW88399_DSP_32_DATA); in aw_cali_svc_get_cali_cfg()
1440 &cali_cfg->data[1], AW88399_DSP_32_DATA); in aw_cali_svc_get_cali_cfg()
1445 &cali_cfg->data[2], AW88399_DSP_16_DATA); in aw_cali_svc_get_cali_cfg()
1450 &cali_cfg->data[3], AW88399_DSP_16_DATA); in aw_cali_svc_get_cali_cfg()
1488 regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG, in aw_cali_svc_cali_en()
1495 dev_err(aw_dev->dev, "get cali cfg failed\n"); in aw_cali_svc_cali_en()
1501 set_cfg.data[2] = -1; in aw_cali_svc_cali_en()
1506 dev_err(aw_dev->dev, "set cali cfg failed\n"); in aw_cali_svc_cali_en()
1507 aw_cali_svc_set_cali_cfg(aw_dev, aw_dev->cali_desc.cali_cfg); in aw_cali_svc_cali_en()
1512 aw_cali_svc_set_cali_cfg(aw_dev, aw_dev->cali_desc.cali_cfg); in aw_cali_svc_cali_en()
1520 static int aw_cali_svc_cali_run_dsp_vol(struct aw_device *aw_dev, bool enable) in aw_cali_svc_cali_run_dsp_vol() argument
1525 if (enable) { in aw_cali_svc_cali_run_dsp_vol()
1526 ret = regmap_read(aw_dev->regmap, AW88399_DSPCFG_REG, ®_val); in aw_cali_svc_cali_run_dsp_vol()
1528 dev_err(aw_dev->dev, "read reg 0x%x failed\n", AW88399_DSPCFG_REG); in aw_cali_svc_cali_run_dsp_vol()
1532 aw_dev->cali_desc.store_vol = reg_val & (~AW88399_DSP_VOL_MASK); in aw_cali_svc_cali_run_dsp_vol()
1533 ret = regmap_update_bits(aw_dev->regmap, AW88399_DSPCFG_REG, in aw_cali_svc_cali_run_dsp_vol()
1536 ret = regmap_update_bits(aw_dev->regmap, AW88399_DSPCFG_REG, in aw_cali_svc_cali_run_dsp_vol()
1537 ~AW88399_DSP_VOL_MASK, aw_dev->cali_desc.store_vol); in aw_cali_svc_cali_run_dsp_vol()
1545 struct aw_cali_backup_desc *backup_desc = &aw_dev->cali_desc.backup_info; in aw_cali_svc_backup_info()
1548 regmap_read(aw_dev->regmap, AW88399_DBGCTRL_REG, ®_val); in aw_cali_svc_backup_info()
1549 backup_desc->dsp_ng_cfg = reg_val & (~AW883XX_DSP_NG_EN_MASK); in aw_cali_svc_backup_info()
1554 backup_desc->dsp_lp_cfg = dsp_val; in aw_cali_svc_backup_info()
1559 struct aw_cali_backup_desc *backup_desc = &aw_dev->cali_desc.backup_info; in aw_cali_svc_recover_info()
1561 regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG, in aw_cali_svc_recover_info()
1562 ~AW883XX_DSP_NG_EN_MASK, backup_desc->dsp_ng_cfg); in aw_cali_svc_recover_info()
1565 backup_desc->dsp_lp_cfg, AW88399_DSP_16_DATA); in aw_cali_svc_recover_info()
1575 dev_err(aw_dev->dev, "pll check failed cannot start\n"); in aw_cali_svc_cali_re_mode_enable()
1581 dev_err(aw_dev->dev, "dsp status error\n"); in aw_cali_svc_cali_re_mode_enable()
1588 dev_err(aw_dev->dev, "aw_cali_svc_cali_en failed\n"); in aw_cali_svc_cali_re_mode_enable()
1618 *re = (uint32_t)(show_re - aw_dev->cali_desc.ra); in aw_cali_svc_get_dev_re()
1627 for (i = 1; i < data_size - 1; i++) in aw_cali_svc_del_max_min_ave_algo()
1630 *dsp_re = sum / (data_size - AW_CALI_DATA_SUM_RM); in aw_cali_svc_del_max_min_ave_algo()
1639 ret = regmap_read(aw_dev->regmap, AW88399_ASR1_REG, ®_data); in aw_cali_svc_get_iv_st()
1641 dev_err(aw_dev->dev, "read 0x%x failed\n", AW88399_ASR1_REG); in aw_cali_svc_get_iv_st()
1651 dev_err(aw_dev->dev, "IV data abnormal, please check\n"); in aw_cali_svc_get_iv_st()
1653 return -EINVAL; in aw_cali_svc_get_iv_st()
1658 return *(int *)a - *(int *)b; in compare_ints()
1680 dev_err(aw_dev->dev, "get iv data failed"); in aw_cali_svc_get_smooth_cali_re()
1685 dev_err(aw_dev->dev, "out range re value: [%d]mohm\n", dsp_re); in aw_cali_svc_get_smooth_cali_re()
1686 aw_dev->cali_desc.cali_re = dsp_re; in aw_cali_svc_get_smooth_cali_re()
1687 aw_dev->cali_desc.cali_result = CALI_RESULT_ERROR; in aw_cali_svc_get_smooth_cali_re()
1688 aw_cali_svc_run_mute(aw_dev, aw_dev->cali_desc.cali_result); in aw_cali_svc_get_smooth_cali_re()
1693 aw_dev->cali_desc.cali_result = CALI_RESULT_NORMAL; in aw_cali_svc_get_smooth_cali_re()
1695 aw_dev->cali_desc.cali_re = dsp_re; in aw_cali_svc_get_smooth_cali_re()
1696 dev_dbg(aw_dev->dev, "re[%d]mohm\n", aw_dev->cali_desc.cali_re); in aw_cali_svc_get_smooth_cali_re()
1699 aw_dev_update_cali_re(&aw_dev->cali_desc); in aw_cali_svc_get_smooth_cali_re()
1705 aw_dev->cali_desc.cali_result = CALI_RESULT_ERROR; in aw_cali_svc_get_smooth_cali_re()
1706 aw_cali_svc_run_mute(aw_dev, aw_dev->cali_desc.cali_result); in aw_cali_svc_get_smooth_cali_re()
1707 return -EINVAL; in aw_cali_svc_get_smooth_cali_re()
1712 struct aw_device *aw_dev = aw88399->aw_pa; in aw_cali_svc_dev_cali_re()
1713 struct aw_cali_desc *cali_desc = &aw_dev->cali_desc; in aw_cali_svc_dev_cali_re()
1716 if (cali_desc->cali_running) { in aw_cali_svc_dev_cali_re()
1717 dev_err(aw_dev->dev, "calibration in progress\n"); in aw_cali_svc_dev_cali_re()
1718 return -EINVAL; in aw_cali_svc_dev_cali_re()
1721 cali_desc->cali_running = true; in aw_cali_svc_dev_cali_re()
1726 dev_err(aw_dev->dev, "start cali re failed\n"); in aw_cali_svc_dev_cali_re()
1734 dev_err(aw_dev->dev, "get cali re failed\n"); in aw_cali_svc_dev_cali_re()
1739 cali_desc->cali_running = false; in aw_cali_svc_dev_cali_re()
1749 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_get_fade_in_time()
1751 ucontrol->value.integer.value[0] = aw_dev->fade_in_time; in aw88399_get_fade_in_time()
1762 (struct soc_mixer_control *)kcontrol->private_value; in aw88399_set_fade_in_time()
1763 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_set_fade_in_time()
1766 time = ucontrol->value.integer.value[0]; in aw88399_set_fade_in_time()
1768 if (time < mc->min || time > mc->max) in aw88399_set_fade_in_time()
1769 return -EINVAL; in aw88399_set_fade_in_time()
1771 if (time != aw_dev->fade_in_time) { in aw88399_set_fade_in_time()
1772 aw_dev->fade_in_time = time; in aw88399_set_fade_in_time()
1784 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_get_fade_out_time()
1786 ucontrol->value.integer.value[0] = aw_dev->fade_out_time; in aw88399_get_fade_out_time()
1797 (struct soc_mixer_control *)kcontrol->private_value; in aw88399_set_fade_out_time()
1798 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_set_fade_out_time()
1801 time = ucontrol->value.integer.value[0]; in aw88399_set_fade_out_time()
1802 if (time < mc->min || time > mc->max) in aw88399_set_fade_out_time()
1803 return -EINVAL; in aw88399_set_fade_out_time()
1805 if (time != aw_dev->fade_out_time) { in aw88399_set_fade_out_time()
1806 aw_dev->fade_out_time = time; in aw88399_set_fade_out_time()
1816 if ((index >= aw_dev->prof_info.count) || (index < 0)) in aw88399_dev_set_profile_index()
1817 return -EINVAL; in aw88399_dev_set_profile_index()
1819 if (aw_dev->prof_index == index) in aw88399_dev_set_profile_index()
1820 return -EINVAL; in aw88399_dev_set_profile_index()
1822 aw_dev->prof_index = index; in aw88399_dev_set_profile_index()
1823 dev_dbg(aw_dev->dev, "set prof[%s]", in aw88399_dev_set_profile_index()
1824 aw_dev->prof_info.prof_name_list[aw_dev->prof_info.prof_desc[index].id]); in aw88399_dev_set_profile_index()
1837 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in aw88399_profile_info()
1838 uinfo->count = 1; in aw88399_profile_info()
1840 count = aw88399->aw_pa->prof_info.count; in aw88399_profile_info()
1842 uinfo->value.enumerated.items = 0; in aw88399_profile_info()
1846 uinfo->value.enumerated.items = count; in aw88399_profile_info()
1848 if (uinfo->value.enumerated.item >= count) in aw88399_profile_info()
1849 uinfo->value.enumerated.item = count - 1; in aw88399_profile_info()
1851 count = uinfo->value.enumerated.item; in aw88399_profile_info()
1853 ret = aw88399_dev_get_prof_name(aw88399->aw_pa, count, &prof_name); in aw88399_profile_info()
1855 strscpy(uinfo->value.enumerated.name, "null"); in aw88399_profile_info()
1859 strscpy(uinfo->value.enumerated.name, prof_name); in aw88399_profile_info()
1870 ucontrol->value.integer.value[0] = aw88399->aw_pa->prof_index; in aw88399_profile_get()
1882 mutex_lock(&aw88399->lock); in aw88399_profile_set()
1883 ret = aw88399_dev_set_profile_index(aw88399->aw_pa, ucontrol->value.integer.value[0]); in aw88399_profile_set()
1885 dev_dbg(codec->dev, "profile index does not change"); in aw88399_profile_set()
1886 mutex_unlock(&aw88399->lock); in aw88399_profile_set()
1890 if (aw88399->aw_pa->status) { in aw88399_profile_set()
1891 aw88399_stop(aw88399->aw_pa); in aw88399_profile_set()
1895 mutex_unlock(&aw88399->lock); in aw88399_profile_set()
1905 struct aw_volume_desc *vol_desc = &aw88399->aw_pa->volume_desc; in aw88399_volume_get()
1907 ucontrol->value.integer.value[0] = vol_desc->ctl_volume; in aw88399_volume_get()
1917 struct aw_volume_desc *vol_desc = &aw88399->aw_pa->volume_desc; in aw88399_volume_set()
1919 (struct soc_mixer_control *)kcontrol->private_value; in aw88399_volume_set()
1922 value = ucontrol->value.integer.value[0]; in aw88399_volume_set()
1923 if (value < mc->min || value > mc->max) in aw88399_volume_set()
1924 return -EINVAL; in aw88399_volume_set()
1926 if (vol_desc->ctl_volume != value) { in aw88399_volume_set()
1927 vol_desc->ctl_volume = value; in aw88399_volume_set()
1928 aw_dev_set_volume(aw88399->aw_pa, vol_desc->ctl_volume); in aw88399_volume_set()
1942 ucontrol->value.integer.value[0] = aw88399->aw_pa->fade_step; in aw88399_get_fade_step()
1953 (struct soc_mixer_control *)kcontrol->private_value; in aw88399_set_fade_step()
1956 value = ucontrol->value.integer.value[0]; in aw88399_set_fade_step()
1957 if (value < mc->min || value > mc->max) in aw88399_set_fade_step()
1958 return -EINVAL; in aw88399_set_fade_step()
1960 if (aw88399->aw_pa->fade_step != value) { in aw88399_set_fade_step()
1961 aw88399->aw_pa->fade_step = value; in aw88399_set_fade_step()
1973 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_re_get()
1975 ucontrol->value.integer.value[0] = aw_dev->cali_desc.cali_re; in aw88399_re_get()
1986 (struct soc_mixer_control *)kcontrol->private_value; in aw88399_re_set()
1987 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_re_set()
1990 value = ucontrol->value.integer.value[0]; in aw88399_re_set()
1991 if (value < mc->min || value > mc->max) in aw88399_re_set()
1992 return -EINVAL; in aw88399_re_set()
1994 if (aw_dev->cali_desc.cali_re != value) { in aw88399_re_set()
1995 aw_dev->cali_desc.cali_re = value; in aw88399_re_set()
2007 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_calib_switch_get()
2009 ucontrol->value.integer.value[0] = aw_dev->cali_desc.cali_switch; in aw88399_calib_switch_get()
2019 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_calib_switch_set()
2021 if (aw_dev->cali_desc.cali_switch == ucontrol->value.integer.value[0]) in aw88399_calib_switch_set()
2024 aw_dev->cali_desc.cali_switch = ucontrol->value.integer.value[0]; in aw88399_calib_switch_set()
2041 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_calib_set()
2043 if (aw_dev->status && aw_dev->cali_desc.cali_switch) in aw88399_calib_set()
2051 struct aw_device *aw_dev = aw88399->aw_pa; in aw88399_dev_init()
2056 dev_err(aw_dev->dev, "aw_dev acf parse failed"); in aw88399_dev_init()
2057 return -EINVAL; in aw88399_dev_init()
2059 aw_dev->fade_in_time = AW88399_1000_US / 10; in aw88399_dev_init()
2060 aw_dev->fade_out_time = AW88399_1000_US >> 1; in aw88399_dev_init()
2061 aw_dev->prof_cur = aw_dev->prof_info.prof_desc[0].id; in aw88399_dev_init()
2062 aw_dev->prof_index = aw_dev->prof_info.prof_desc[0].id; in aw88399_dev_init()
2066 dev_err(aw_dev->dev, "fw update failed ret = %d\n", ret); in aw88399_dev_init()
2076 /* enable amppd */ in aw88399_dev_init()
2092 aw88399->aw_pa->fw_status = AW88399_DEV_FW_FAILED; in aw88399_request_firmware_file()
2094 ret = request_firmware(&cont, AW88399_ACF_FILE, aw88399->aw_pa->dev); in aw88399_request_firmware_file()
2096 dev_err(aw88399->aw_pa->dev, "request [%s] failed!", AW88399_ACF_FILE); in aw88399_request_firmware_file()
2100 dev_dbg(aw88399->aw_pa->dev, "loaded %s - size: %zu\n", in aw88399_request_firmware_file()
2101 AW88399_ACF_FILE, cont ? cont->size : 0); in aw88399_request_firmware_file()
2103 aw88399->aw_cfg = devm_kzalloc(aw88399->aw_pa->dev, in aw88399_request_firmware_file()
2104 struct_size(aw88399->aw_cfg, data, cont->size), GFP_KERNEL); in aw88399_request_firmware_file()
2105 if (!aw88399->aw_cfg) { in aw88399_request_firmware_file()
2107 return -ENOMEM; in aw88399_request_firmware_file()
2109 aw88399->aw_cfg->len = (int)cont->size; in aw88399_request_firmware_file()
2110 memcpy(aw88399->aw_cfg->data, cont->data, cont->size); in aw88399_request_firmware_file()
2113 ret = aw88395_dev_load_acf_check(aw88399->aw_pa, aw88399->aw_cfg); in aw88399_request_firmware_file()
2115 dev_err(aw88399->aw_pa->dev, "load [%s] failed!", AW88399_ACF_FILE); in aw88399_request_firmware_file()
2119 mutex_lock(&aw88399->lock); in aw88399_request_firmware_file()
2121 ret = aw88399_dev_init(aw88399, aw88399->aw_cfg); in aw88399_request_firmware_file()
2123 dev_err(aw88399->aw_pa->dev, "dev init failed"); in aw88399_request_firmware_file()
2124 mutex_unlock(&aw88399->lock); in aw88399_request_firmware_file()
2152 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aw88399_playback_event()
2155 mutex_lock(&aw88399->lock); in aw88399_playback_event()
2161 aw88399_stop(aw88399->aw_pa); in aw88399_playback_event()
2166 mutex_unlock(&aw88399->lock); in aw88399_playback_event()
2193 INIT_DELAYED_WORK(&aw88399->start_work, aw88399_startup_work); in aw88399_codec_probe()
2197 dev_err(aw88399->aw_pa->dev, "%s failed\n", __func__); in aw88399_codec_probe()
2206 cancel_delayed_work_sync(&aw88399->start_work); in aw88399_codec_remove()
2222 if (aw88399->reset_gpio) { in aw88399_hw_reset()
2223 gpiod_set_value_cansleep(aw88399->reset_gpio, 1); in aw88399_hw_reset()
2225 gpiod_set_value_cansleep(aw88399->reset_gpio, 0); in aw88399_hw_reset()
2227 gpiod_set_value_cansleep(aw88399->reset_gpio, 1); in aw88399_hw_reset()
2234 struct device_node *np = aw_dev->dev->of_node; in aw88399_parse_channel_dt()
2237 of_property_read_u32(np, "awinic,audio-channel", &channel_value); in aw88399_parse_channel_dt()
2238 aw_dev->channel = channel_value; in aw88399_parse_channel_dt()
2241 static int aw88399_init(struct aw88399 *aw88399, struct i2c_client *i2c, struct regmap *regmap) in aw88399_init() argument
2249 dev_err(&i2c->dev, "%s read chipid error. ret = %d", __func__, ret); in aw88399_init()
2253 dev_err(&i2c->dev, "unsupported device"); in aw88399_init()
2254 return -ENXIO; in aw88399_init()
2256 dev_dbg(&i2c->dev, "chip id = %x\n", chip_id); in aw88399_init()
2258 aw_dev = devm_kzalloc(&i2c->dev, sizeof(*aw_dev), GFP_KERNEL); in aw88399_init()
2260 return -ENOMEM; in aw88399_init()
2261 aw88399->aw_pa = aw_dev; in aw88399_init()
2263 aw_dev->i2c = i2c; in aw88399_init()
2264 aw_dev->dev = &i2c->dev; in aw88399_init()
2265 aw_dev->regmap = regmap; in aw88399_init()
2266 mutex_init(&aw_dev->dsp_lock); in aw88399_init()
2268 aw_dev->chip_id = chip_id; in aw88399_init()
2269 aw_dev->acf = NULL; in aw88399_init()
2270 aw_dev->prof_info.prof_desc = NULL; in aw88399_init()
2271 aw_dev->prof_info.count = 0; in aw88399_init()
2272 aw_dev->prof_info.prof_type = AW88395_DEV_NONE_TYPE_ID; in aw88399_init()
2273 aw_dev->channel = AW88399_DEV_DEFAULT_CH; in aw88399_init()
2274 aw_dev->fw_status = AW88399_DEV_FW_FAILED; in aw88399_init()
2276 aw_dev->fade_step = AW88399_VOLUME_STEP_DB; in aw88399_init()
2277 aw_dev->volume_desc.ctl_volume = AW88399_VOL_DEFAULT_VALUE; in aw88399_init()
2284 static int aw88399_i2c_probe(struct i2c_client *i2c) in aw88399_i2c_probe() argument
2289 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C)) in aw88399_i2c_probe()
2290 return dev_err_probe(&i2c->dev, -ENXIO, "check_functionality failed"); in aw88399_i2c_probe()
2292 aw88399 = devm_kzalloc(&i2c->dev, sizeof(*aw88399), GFP_KERNEL); in aw88399_i2c_probe()
2294 return -ENOMEM; in aw88399_i2c_probe()
2296 mutex_init(&aw88399->lock); in aw88399_i2c_probe()
2298 i2c_set_clientdata(i2c, aw88399); in aw88399_i2c_probe()
2300 aw88399->reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_LOW); in aw88399_i2c_probe()
2301 if (IS_ERR(aw88399->reset_gpio)) in aw88399_i2c_probe()
2302 return dev_err_probe(&i2c->dev, PTR_ERR(aw88399->reset_gpio), in aw88399_i2c_probe()
2306 aw88399->regmap = devm_regmap_init_i2c(i2c, &aw88399_remap_config); in aw88399_i2c_probe()
2307 if (IS_ERR(aw88399->regmap)) in aw88399_i2c_probe()
2308 return dev_err_probe(&i2c->dev, PTR_ERR(aw88399->regmap), in aw88399_i2c_probe()
2312 ret = aw88399_init(aw88399, i2c, aw88399->regmap); in aw88399_i2c_probe()
2316 ret = devm_snd_soc_register_component(&i2c->dev, in aw88399_i2c_probe()
2320 dev_err(&i2c->dev, "failed to register aw88399: %d", ret); in aw88399_i2c_probe()
2329 MODULE_DEVICE_TABLE(i2c, aw88399_i2c_id);