Lines Matching refs:aw_dev
28 static void aw88261_dev_set_volume(struct aw_device *aw_dev, unsigned int value) in aw88261_dev_set_volume() argument
30 struct aw_volume_desc *vol_desc = &aw_dev->volume_desc; in aw88261_dev_set_volume()
37 regmap_read(aw_dev->regmap, AW88261_SYSCTRL2_REG, ®_value); in aw88261_dev_set_volume()
41 dev_dbg(aw_dev->dev, "value 0x%x , real_value:0x%x", value, real_value); in aw88261_dev_set_volume()
43 regmap_write(aw_dev->regmap, AW88261_SYSCTRL2_REG, real_value); in aw88261_dev_set_volume()
46 static void aw88261_dev_fade_in(struct aw_device *aw_dev) in aw88261_dev_fade_in() argument
48 struct aw_volume_desc *desc = &aw_dev->volume_desc; in aw88261_dev_fade_in()
50 int fade_step = aw_dev->fade_step; in aw88261_dev_fade_in()
53 if (fade_step == 0 || aw_dev->fade_in_time == 0) { in aw88261_dev_fade_in()
54 aw88261_dev_set_volume(aw_dev, fade_in_vol); in aw88261_dev_fade_in()
59 aw88261_dev_set_volume(aw_dev, i); in aw88261_dev_fade_in()
60 usleep_range(aw_dev->fade_in_time, in aw88261_dev_fade_in()
61 aw_dev->fade_in_time + 10); in aw88261_dev_fade_in()
65 aw88261_dev_set_volume(aw_dev, fade_in_vol); in aw88261_dev_fade_in()
68 static void aw88261_dev_fade_out(struct aw_device *aw_dev) in aw88261_dev_fade_out() argument
70 struct aw_volume_desc *desc = &aw_dev->volume_desc; in aw88261_dev_fade_out()
71 int fade_step = aw_dev->fade_step; in aw88261_dev_fade_out()
74 if (fade_step == 0 || aw_dev->fade_out_time == 0) { in aw88261_dev_fade_out()
75 aw88261_dev_set_volume(aw_dev, AW88261_MUTE_VOL); in aw88261_dev_fade_out()
80 aw88261_dev_set_volume(aw_dev, i); in aw88261_dev_fade_out()
81 usleep_range(aw_dev->fade_out_time, aw_dev->fade_out_time + 10); in aw88261_dev_fade_out()
85 aw88261_dev_set_volume(aw_dev, AW88261_MUTE_VOL); in aw88261_dev_fade_out()
86 usleep_range(aw_dev->fade_out_time, aw_dev->fade_out_time + 10); in aw88261_dev_fade_out()
90 static void aw88261_dev_i2s_tx_enable(struct aw_device *aw_dev, bool flag) in aw88261_dev_i2s_tx_enable() argument
93 regmap_update_bits(aw_dev->regmap, AW88261_I2SCFG1_REG, in aw88261_dev_i2s_tx_enable()
96 regmap_update_bits(aw_dev->regmap, AW88261_I2SCFG1_REG, in aw88261_dev_i2s_tx_enable()
100 static void aw88261_dev_pwd(struct aw_device *aw_dev, bool pwd) in aw88261_dev_pwd() argument
103 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_pwd()
106 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_pwd()
110 static void aw88261_dev_amppd(struct aw_device *aw_dev, bool amppd) in aw88261_dev_amppd() argument
113 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_amppd()
116 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_amppd()
120 static void aw88261_dev_mute(struct aw_device *aw_dev, bool is_mute) in aw88261_dev_mute() argument
123 aw88261_dev_fade_out(aw_dev); in aw88261_dev_mute()
124 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_mute()
127 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_mute()
129 aw88261_dev_fade_in(aw_dev); in aw88261_dev_mute()
133 static void aw88261_dev_clear_int_status(struct aw_device *aw_dev) in aw88261_dev_clear_int_status() argument
138 regmap_read(aw_dev->regmap, AW88261_SYSINT_REG, &int_status); in aw88261_dev_clear_int_status()
140 regmap_read(aw_dev->regmap, AW88261_SYSINT_REG, &int_status); in aw88261_dev_clear_int_status()
142 dev_dbg(aw_dev->dev, "read interrupt reg = 0x%04x", int_status); in aw88261_dev_clear_int_status()
145 static int aw88261_dev_get_iis_status(struct aw_device *aw_dev) in aw88261_dev_get_iis_status() argument
150 ret = regmap_read(aw_dev->regmap, AW88261_SYSST_REG, ®_val); in aw88261_dev_get_iis_status()
154 dev_err(aw_dev->dev, "check pll lock fail,reg_val:0x%04x", reg_val); in aw88261_dev_get_iis_status()
161 static int aw88261_dev_check_mode1_pll(struct aw_device *aw_dev) in aw88261_dev_check_mode1_pll() argument
166 ret = aw88261_dev_get_iis_status(aw_dev); in aw88261_dev_check_mode1_pll()
168 dev_err(aw_dev->dev, "mode1 iis signal check error"); in aw88261_dev_check_mode1_pll()
178 static int aw88261_dev_check_mode2_pll(struct aw_device *aw_dev) in aw88261_dev_check_mode2_pll() argument
183 ret = regmap_read(aw_dev->regmap, AW88261_PLLCTRL1_REG, ®_val); in aw88261_dev_check_mode2_pll()
189 dev_dbg(aw_dev->dev, "CCO_MUX is already divider"); in aw88261_dev_check_mode2_pll()
194 ret = regmap_update_bits(aw_dev->regmap, AW88261_PLLCTRL1_REG, in aw88261_dev_check_mode2_pll()
200 ret = aw88261_dev_get_iis_status(aw_dev); in aw88261_dev_check_mode2_pll()
202 dev_err(aw_dev->dev, "mode2 iis signal check error"); in aw88261_dev_check_mode2_pll()
210 ret = regmap_update_bits(aw_dev->regmap, AW88261_PLLCTRL1_REG, in aw88261_dev_check_mode2_pll()
215 ret = aw88261_dev_check_mode1_pll(aw_dev); in aw88261_dev_check_mode2_pll()
217 dev_err(aw_dev->dev, "mode2 switch to mode1, iis signal check error"); in aw88261_dev_check_mode2_pll()
228 static int aw88261_dev_check_syspll(struct aw_device *aw_dev) in aw88261_dev_check_syspll() argument
232 ret = aw88261_dev_check_mode1_pll(aw_dev); in aw88261_dev_check_syspll()
234 dev_dbg(aw_dev->dev, "mode1 check iis failed try switch to mode2 check"); in aw88261_dev_check_syspll()
235 ret = aw88261_dev_check_mode2_pll(aw_dev); in aw88261_dev_check_syspll()
237 dev_err(aw_dev->dev, "mode2 check iis failed"); in aw88261_dev_check_syspll()
245 static int aw88261_dev_check_sysst(struct aw_device *aw_dev) in aw88261_dev_check_sysst() argument
252 ret = regmap_read(aw_dev->regmap, AW88261_SYSST_REG, ®_val); in aw88261_dev_check_sysst()
259 dev_err(aw_dev->dev, "check sysst fail, reg_val=0x%04x, check:0x%x", in aw88261_dev_check_sysst()
270 static void aw88261_dev_uls_hmute(struct aw_device *aw_dev, bool uls_hmute) in aw88261_dev_uls_hmute() argument
273 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_uls_hmute()
277 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_uls_hmute()
308 static int aw88261_dev_get_icalk(struct aw_device *aw_dev, int16_t *icalk) in aw88261_dev_get_icalk() argument
314 ret = regmap_read(aw_dev->regmap, AW88261_EFRH4_REG, ®_val); in aw88261_dev_get_icalk()
320 ret = regmap_read(aw_dev->regmap, AW88261_EFRL4_REG, ®_val); in aw88261_dev_get_icalk()
336 static int aw88261_dev_get_vcalk(struct aw_device *aw_dev, int16_t *vcalk) in aw88261_dev_get_vcalk() argument
342 ret = regmap_read(aw_dev->regmap, AW88261_EFRH3_REG, ®_val); in aw88261_dev_get_vcalk()
348 ret = regmap_read(aw_dev->regmap, AW88261_EFRL3_REG, ®_val); in aw88261_dev_get_vcalk()
363 static int aw88261_dev_set_vcalb(struct aw_device *aw_dev) in aw88261_dev_set_vcalb() argument
370 ret = aw88261_dev_get_icalk(aw_dev, &icalk_val); in aw88261_dev_set_vcalb()
374 ret = aw88261_dev_get_vcalk(aw_dev, &vcalk_val); in aw88261_dev_set_vcalb()
386 dev_dbg(aw_dev->dev, "icalk=%d, vcalk=%d, vcalb=%d, reg_val=0x%04x", in aw88261_dev_set_vcalb()
388 ret = regmap_write(aw_dev->regmap, AW88261_VSNTM1_REG, reg_val); in aw88261_dev_set_vcalb()
396 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_dev_reg_update() local
397 struct aw_volume_desc *vol_desc = &aw_dev->volume_desc; in aw88261_dev_reg_update()
405 dev_err(aw_dev->dev, "reg data is null or len is 0"); in aw88261_dev_reg_update()
413 dev_err(aw_dev->dev, "data len:%d unsupported", data_len); in aw88261_dev_reg_update()
423 ret = regmap_read(aw_dev->regmap, reg_addr, &read_val); in aw88261_dev_reg_update()
455 aw_dev->volume_desc.init_volume = in aw88261_dev_reg_update()
462 ret = regmap_write(aw_dev->regmap, reg_addr, reg_val); in aw88261_dev_reg_update()
467 ret = aw88261_dev_set_vcalb(aw_dev); in aw88261_dev_reg_update()
471 if (aw_dev->prof_cur != aw_dev->prof_index) in aw88261_dev_reg_update()
475 aw88261_dev_set_volume(aw_dev, vol_desc->mute_volume); in aw88261_dev_reg_update()
480 static char *aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index) in aw88261_dev_get_prof_name() argument
482 struct aw_prof_info *prof_info = &aw_dev->prof_info; in aw88261_dev_get_prof_name()
485 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw88261_dev_get_prof_name()
486 dev_err(aw_dev->dev, "index[%d] overflow count[%d]", in aw88261_dev_get_prof_name()
487 index, aw_dev->prof_info.count); in aw88261_dev_get_prof_name()
491 prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw88261_dev_get_prof_name()
496 static int aw88261_dev_get_prof_data(struct aw_device *aw_dev, int index, in aw88261_dev_get_prof_data() argument
499 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw88261_dev_get_prof_data()
500 dev_err(aw_dev->dev, "%s: index[%d] overflow count[%d]\n", in aw88261_dev_get_prof_data()
501 __func__, index, aw_dev->prof_info.count); in aw88261_dev_get_prof_data()
505 *prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw88261_dev_get_prof_data()
512 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_dev_fw_update() local
518 prof_name = aw88261_dev_get_prof_name(aw_dev, aw_dev->prof_index); in aw88261_dev_fw_update()
520 dev_err(aw_dev->dev, "get prof name failed"); in aw88261_dev_fw_update()
524 dev_dbg(aw_dev->dev, "start update %s", prof_name); in aw88261_dev_fw_update()
526 ret = aw88261_dev_get_prof_data(aw_dev, aw_dev->prof_index, &prof_index_desc); in aw88261_dev_fw_update()
535 dev_err(aw_dev->dev, "update reg failed"); in aw88261_dev_fw_update()
539 aw_dev->prof_cur = aw_dev->prof_index; in aw88261_dev_fw_update()
546 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_dev_start() local
549 if (aw_dev->status == AW88261_DEV_PW_ON) { in aw88261_dev_start()
550 dev_info(aw_dev->dev, "already power on"); in aw88261_dev_start()
555 aw88261_dev_pwd(aw_dev, false); in aw88261_dev_start()
558 ret = aw88261_dev_check_syspll(aw_dev); in aw88261_dev_start()
560 dev_err(aw_dev->dev, "pll check failed cannot start"); in aw88261_dev_start()
565 aw88261_dev_amppd(aw_dev, false); in aw88261_dev_start()
569 ret = aw88261_dev_check_sysst(aw_dev); in aw88261_dev_start()
571 dev_err(aw_dev->dev, "sysst check failed"); in aw88261_dev_start()
576 aw88261_dev_i2s_tx_enable(aw_dev, true); in aw88261_dev_start()
579 aw88261_dev_amppd(aw_dev, true); in aw88261_dev_start()
584 aw88261_dev_uls_hmute(aw_dev, false); in aw88261_dev_start()
588 aw88261_dev_mute(aw_dev, false); in aw88261_dev_start()
591 aw88261_dev_clear_int_status(aw_dev); in aw88261_dev_start()
592 aw_dev->status = AW88261_DEV_PW_ON; in aw88261_dev_start()
597 aw88261_dev_i2s_tx_enable(aw_dev, false); in aw88261_dev_start()
598 aw88261_dev_clear_int_status(aw_dev); in aw88261_dev_start()
599 aw88261_dev_amppd(aw_dev, true); in aw88261_dev_start()
601 aw88261_dev_pwd(aw_dev, true); in aw88261_dev_start()
602 aw_dev->status = AW88261_DEV_PW_OFF; in aw88261_dev_start()
607 static int aw88261_dev_stop(struct aw_device *aw_dev) in aw88261_dev_stop() argument
609 if (aw_dev->status == AW88261_DEV_PW_OFF) { in aw88261_dev_stop()
610 dev_info(aw_dev->dev, "already power off"); in aw88261_dev_stop()
614 aw_dev->status = AW88261_DEV_PW_OFF; in aw88261_dev_stop()
617 aw88261_dev_clear_int_status(aw_dev); in aw88261_dev_stop()
619 aw88261_dev_uls_hmute(aw_dev, true); in aw88261_dev_stop()
621 aw88261_dev_mute(aw_dev, true); in aw88261_dev_stop()
624 aw88261_dev_i2s_tx_enable(aw_dev, false); in aw88261_dev_stop()
628 aw88261_dev_amppd(aw_dev, true); in aw88261_dev_stop()
631 aw88261_dev_pwd(aw_dev, true); in aw88261_dev_stop()
638 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_reg_update() local
642 ret = regmap_write(aw_dev->regmap, in aw88261_reg_update()
651 if (aw_dev->prof_cur != aw_dev->prof_index) { in aw88261_reg_update()
660 aw_dev->prof_cur = aw_dev->prof_index; in aw88261_reg_update()
738 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_get_fade_in_time() local
740 ucontrol->value.integer.value[0] = aw_dev->fade_in_time; in aw88261_get_fade_in_time()
752 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_set_fade_in_time() local
760 if (time != aw_dev->fade_in_time) { in aw88261_set_fade_in_time()
761 aw_dev->fade_in_time = time; in aw88261_set_fade_in_time()
773 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_get_fade_out_time() local
775 ucontrol->value.integer.value[0] = aw_dev->fade_out_time; in aw88261_get_fade_out_time()
787 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_set_fade_out_time() local
794 if (time != aw_dev->fade_out_time) { in aw88261_set_fade_out_time()
795 aw_dev->fade_out_time = time; in aw88261_set_fade_out_time()
802 static int aw88261_dev_set_profile_index(struct aw_device *aw_dev, int index) in aw88261_dev_set_profile_index() argument
805 if ((index >= aw_dev->prof_info.count) || (index < 0)) in aw88261_dev_set_profile_index()
808 if (aw_dev->prof_index == index) in aw88261_dev_set_profile_index()
811 aw_dev->prof_index = index; in aw88261_dev_set_profile_index()
1047 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_dev_init() local
1050 ret = aw88395_dev_cfg_load(aw_dev, aw_cfg); in aw88261_dev_init()
1052 dev_err(aw_dev->dev, "aw_dev acf parse failed"); in aw88261_dev_init()
1056 ret = regmap_write(aw_dev->regmap, AW88261_ID_REG, AW88261_SOFT_RESET_VALUE); in aw88261_dev_init()
1060 aw_dev->fade_in_time = AW88261_500_US; in aw88261_dev_init()
1061 aw_dev->fade_out_time = AW88261_500_US; in aw88261_dev_init()
1062 aw_dev->prof_cur = AW88261_INIT_PROFILE; in aw88261_dev_init()
1063 aw_dev->prof_index = AW88261_INIT_PROFILE; in aw88261_dev_init()
1067 dev_err(aw_dev->dev, "fw update failed ret = %d\n", ret); in aw88261_dev_init()
1073 dev_err(aw_dev->dev, "aw88261_frcset_check ret = %d\n", ret); in aw88261_dev_init()
1077 aw88261_dev_clear_int_status(aw_dev); in aw88261_dev_init()
1079 aw88261_dev_uls_hmute(aw_dev, true); in aw88261_dev_init()
1081 aw88261_dev_mute(aw_dev, true); in aw88261_dev_init()
1083 aw88261_dev_i2s_tx_enable(aw_dev, false); in aw88261_dev_init()
1087 aw88261_dev_amppd(aw_dev, true); in aw88261_dev_init()
1089 aw88261_dev_pwd(aw_dev, true); in aw88261_dev_init()
1187 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_parse_channel_dt() local
1188 struct device_node *np = aw_dev->dev->of_node; in aw88261_parse_channel_dt()
1195 aw_dev->channel = channel_value; in aw88261_parse_channel_dt()
1201 struct aw_device *aw_dev; in aw88261_init() local
1218 aw_dev = devm_kzalloc(&i2c->dev, sizeof(*aw_dev), GFP_KERNEL); in aw88261_init()
1219 if (!aw_dev) in aw88261_init()
1222 (*aw88261)->aw_pa = aw_dev; in aw88261_init()
1223 aw_dev->i2c = i2c; in aw88261_init()
1224 aw_dev->regmap = regmap; in aw88261_init()
1225 aw_dev->dev = &i2c->dev; in aw88261_init()
1226 aw_dev->chip_id = AW88261_CHIP_ID; in aw88261_init()
1227 aw_dev->acf = NULL; in aw88261_init()
1228 aw_dev->prof_info.prof_desc = NULL; in aw88261_init()
1229 aw_dev->prof_info.count = 0; in aw88261_init()
1230 aw_dev->prof_info.prof_type = AW88395_DEV_NONE_TYPE_ID; in aw88261_init()
1231 aw_dev->channel = 0; in aw88261_init()
1232 aw_dev->fw_status = AW88261_DEV_FW_FAILED; in aw88261_init()
1233 aw_dev->fade_step = AW88261_VOLUME_STEP_DB; in aw88261_init()
1234 aw_dev->volume_desc.ctl_volume = AW88261_VOL_DEFAULT_VALUE; in aw88261_init()
1235 aw_dev->volume_desc.mute_volume = AW88261_MUTE_VOL; in aw88261_init()