Lines Matching refs:aw_dev
27 static void aw88261_dev_set_volume(struct aw_device *aw_dev, unsigned int value) in aw88261_dev_set_volume() argument
29 struct aw_volume_desc *vol_desc = &aw_dev->volume_desc; in aw88261_dev_set_volume()
36 regmap_read(aw_dev->regmap, AW88261_SYSCTRL2_REG, ®_value); in aw88261_dev_set_volume()
40 dev_dbg(aw_dev->dev, "value 0x%x , real_value:0x%x", value, real_value); in aw88261_dev_set_volume()
42 regmap_write(aw_dev->regmap, AW88261_SYSCTRL2_REG, real_value); in aw88261_dev_set_volume()
45 static void aw88261_dev_fade_in(struct aw_device *aw_dev) in aw88261_dev_fade_in() argument
47 struct aw_volume_desc *desc = &aw_dev->volume_desc; in aw88261_dev_fade_in()
49 int fade_step = aw_dev->fade_step; in aw88261_dev_fade_in()
52 if (fade_step == 0 || aw_dev->fade_in_time == 0) { in aw88261_dev_fade_in()
53 aw88261_dev_set_volume(aw_dev, fade_in_vol); in aw88261_dev_fade_in()
58 aw88261_dev_set_volume(aw_dev, i); in aw88261_dev_fade_in()
59 usleep_range(aw_dev->fade_in_time, in aw88261_dev_fade_in()
60 aw_dev->fade_in_time + 10); in aw88261_dev_fade_in()
64 aw88261_dev_set_volume(aw_dev, fade_in_vol); in aw88261_dev_fade_in()
67 static void aw88261_dev_fade_out(struct aw_device *aw_dev) in aw88261_dev_fade_out() argument
69 struct aw_volume_desc *desc = &aw_dev->volume_desc; in aw88261_dev_fade_out()
70 int fade_step = aw_dev->fade_step; in aw88261_dev_fade_out()
73 if (fade_step == 0 || aw_dev->fade_out_time == 0) { in aw88261_dev_fade_out()
74 aw88261_dev_set_volume(aw_dev, AW88261_MUTE_VOL); in aw88261_dev_fade_out()
79 aw88261_dev_set_volume(aw_dev, i); in aw88261_dev_fade_out()
80 usleep_range(aw_dev->fade_out_time, aw_dev->fade_out_time + 10); in aw88261_dev_fade_out()
84 aw88261_dev_set_volume(aw_dev, AW88261_MUTE_VOL); in aw88261_dev_fade_out()
85 usleep_range(aw_dev->fade_out_time, aw_dev->fade_out_time + 10); in aw88261_dev_fade_out()
89 static void aw88261_dev_i2s_tx_enable(struct aw_device *aw_dev, bool flag) in aw88261_dev_i2s_tx_enable() argument
92 regmap_update_bits(aw_dev->regmap, AW88261_I2SCFG1_REG, in aw88261_dev_i2s_tx_enable()
95 regmap_update_bits(aw_dev->regmap, AW88261_I2SCFG1_REG, in aw88261_dev_i2s_tx_enable()
99 static void aw88261_dev_pwd(struct aw_device *aw_dev, bool pwd) in aw88261_dev_pwd() argument
102 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_pwd()
105 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_pwd()
109 static void aw88261_dev_amppd(struct aw_device *aw_dev, bool amppd) in aw88261_dev_amppd() argument
112 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_amppd()
115 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_amppd()
119 static void aw88261_dev_mute(struct aw_device *aw_dev, bool is_mute) in aw88261_dev_mute() argument
122 aw88261_dev_fade_out(aw_dev); in aw88261_dev_mute()
123 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_mute()
126 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_mute()
128 aw88261_dev_fade_in(aw_dev); in aw88261_dev_mute()
132 static void aw88261_dev_clear_int_status(struct aw_device *aw_dev) in aw88261_dev_clear_int_status() argument
137 regmap_read(aw_dev->regmap, AW88261_SYSINT_REG, &int_status); in aw88261_dev_clear_int_status()
139 regmap_read(aw_dev->regmap, AW88261_SYSINT_REG, &int_status); in aw88261_dev_clear_int_status()
141 dev_dbg(aw_dev->dev, "read interrupt reg = 0x%04x", int_status); in aw88261_dev_clear_int_status()
144 static int aw88261_dev_get_iis_status(struct aw_device *aw_dev) in aw88261_dev_get_iis_status() argument
149 ret = regmap_read(aw_dev->regmap, AW88261_SYSST_REG, ®_val); in aw88261_dev_get_iis_status()
153 dev_err(aw_dev->dev, "check pll lock fail,reg_val:0x%04x", reg_val); in aw88261_dev_get_iis_status()
160 static int aw88261_dev_check_mode1_pll(struct aw_device *aw_dev) in aw88261_dev_check_mode1_pll() argument
165 ret = aw88261_dev_get_iis_status(aw_dev); in aw88261_dev_check_mode1_pll()
167 dev_err(aw_dev->dev, "mode1 iis signal check error"); in aw88261_dev_check_mode1_pll()
177 static int aw88261_dev_check_mode2_pll(struct aw_device *aw_dev) in aw88261_dev_check_mode2_pll() argument
182 ret = regmap_read(aw_dev->regmap, AW88261_PLLCTRL1_REG, ®_val); in aw88261_dev_check_mode2_pll()
188 dev_dbg(aw_dev->dev, "CCO_MUX is already divider"); in aw88261_dev_check_mode2_pll()
193 ret = regmap_update_bits(aw_dev->regmap, AW88261_PLLCTRL1_REG, in aw88261_dev_check_mode2_pll()
199 ret = aw88261_dev_get_iis_status(aw_dev); in aw88261_dev_check_mode2_pll()
201 dev_err(aw_dev->dev, "mode2 iis signal check error"); in aw88261_dev_check_mode2_pll()
209 ret = regmap_update_bits(aw_dev->regmap, AW88261_PLLCTRL1_REG, in aw88261_dev_check_mode2_pll()
214 ret = aw88261_dev_check_mode1_pll(aw_dev); in aw88261_dev_check_mode2_pll()
216 dev_err(aw_dev->dev, "mode2 switch to mode1, iis signal check error"); in aw88261_dev_check_mode2_pll()
227 static int aw88261_dev_check_syspll(struct aw_device *aw_dev) in aw88261_dev_check_syspll() argument
231 ret = aw88261_dev_check_mode1_pll(aw_dev); in aw88261_dev_check_syspll()
233 dev_dbg(aw_dev->dev, "mode1 check iis failed try switch to mode2 check"); in aw88261_dev_check_syspll()
234 ret = aw88261_dev_check_mode2_pll(aw_dev); in aw88261_dev_check_syspll()
236 dev_err(aw_dev->dev, "mode2 check iis failed"); in aw88261_dev_check_syspll()
244 static int aw88261_dev_check_sysst(struct aw_device *aw_dev) in aw88261_dev_check_sysst() argument
251 ret = regmap_read(aw_dev->regmap, AW88261_SYSST_REG, ®_val); in aw88261_dev_check_sysst()
258 dev_err(aw_dev->dev, "check sysst fail, reg_val=0x%04x, check:0x%x", in aw88261_dev_check_sysst()
269 static void aw88261_dev_uls_hmute(struct aw_device *aw_dev, bool uls_hmute) in aw88261_dev_uls_hmute() argument
272 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_uls_hmute()
276 regmap_update_bits(aw_dev->regmap, AW88261_SYSCTRL_REG, in aw88261_dev_uls_hmute()
307 static int aw88261_dev_get_icalk(struct aw_device *aw_dev, int16_t *icalk) in aw88261_dev_get_icalk() argument
313 ret = regmap_read(aw_dev->regmap, AW88261_EFRH4_REG, ®_val); in aw88261_dev_get_icalk()
319 ret = regmap_read(aw_dev->regmap, AW88261_EFRL4_REG, ®_val); in aw88261_dev_get_icalk()
335 static int aw88261_dev_get_vcalk(struct aw_device *aw_dev, int16_t *vcalk) in aw88261_dev_get_vcalk() argument
341 ret = regmap_read(aw_dev->regmap, AW88261_EFRH3_REG, ®_val); in aw88261_dev_get_vcalk()
347 ret = regmap_read(aw_dev->regmap, AW88261_EFRL3_REG, ®_val); in aw88261_dev_get_vcalk()
362 static int aw88261_dev_set_vcalb(struct aw_device *aw_dev) in aw88261_dev_set_vcalb() argument
369 ret = aw88261_dev_get_icalk(aw_dev, &icalk_val); in aw88261_dev_set_vcalb()
373 ret = aw88261_dev_get_vcalk(aw_dev, &vcalk_val); in aw88261_dev_set_vcalb()
385 dev_dbg(aw_dev->dev, "icalk=%d, vcalk=%d, vcalb=%d, reg_val=0x%04x", in aw88261_dev_set_vcalb()
387 ret = regmap_write(aw_dev->regmap, AW88261_VSNTM1_REG, reg_val); in aw88261_dev_set_vcalb()
395 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_dev_reg_update() local
396 struct aw_volume_desc *vol_desc = &aw_dev->volume_desc; in aw88261_dev_reg_update()
404 dev_err(aw_dev->dev, "reg data is null or len is 0"); in aw88261_dev_reg_update()
412 dev_err(aw_dev->dev, "data len:%d unsupported", data_len); in aw88261_dev_reg_update()
422 ret = regmap_read(aw_dev->regmap, reg_addr, &read_val); in aw88261_dev_reg_update()
454 aw_dev->volume_desc.init_volume = in aw88261_dev_reg_update()
461 ret = regmap_write(aw_dev->regmap, reg_addr, reg_val); in aw88261_dev_reg_update()
466 ret = aw88261_dev_set_vcalb(aw_dev); in aw88261_dev_reg_update()
470 if (aw_dev->prof_cur != aw_dev->prof_index) in aw88261_dev_reg_update()
474 aw88261_dev_set_volume(aw_dev, vol_desc->mute_volume); in aw88261_dev_reg_update()
479 static int aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index, char **prof_name) in aw88261_dev_get_prof_name() argument
481 struct aw_prof_info *prof_info = &aw_dev->prof_info; in aw88261_dev_get_prof_name()
484 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw88261_dev_get_prof_name()
485 dev_err(aw_dev->dev, "index[%d] overflow count[%d]", in aw88261_dev_get_prof_name()
486 index, aw_dev->prof_info.count); in aw88261_dev_get_prof_name()
490 prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw88261_dev_get_prof_name()
497 static int aw88261_dev_get_prof_data(struct aw_device *aw_dev, int index, in aw88261_dev_get_prof_data() argument
500 if ((index >= aw_dev->prof_info.count) || (index < 0)) { in aw88261_dev_get_prof_data()
501 dev_err(aw_dev->dev, "%s: index[%d] overflow count[%d]\n", in aw88261_dev_get_prof_data()
502 __func__, index, aw_dev->prof_info.count); in aw88261_dev_get_prof_data()
506 *prof_desc = &aw_dev->prof_info.prof_desc[index]; in aw88261_dev_get_prof_data()
513 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_dev_fw_update() local
519 ret = aw88261_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name); in aw88261_dev_fw_update()
521 dev_err(aw_dev->dev, "get prof name failed"); in aw88261_dev_fw_update()
525 dev_dbg(aw_dev->dev, "start update %s", prof_name); in aw88261_dev_fw_update()
527 ret = aw88261_dev_get_prof_data(aw_dev, aw_dev->prof_index, &prof_index_desc); in aw88261_dev_fw_update()
536 dev_err(aw_dev->dev, "update reg failed"); in aw88261_dev_fw_update()
540 aw_dev->prof_cur = aw_dev->prof_index; in aw88261_dev_fw_update()
547 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_dev_start() local
550 if (aw_dev->status == AW88261_DEV_PW_ON) { in aw88261_dev_start()
551 dev_info(aw_dev->dev, "already power on"); in aw88261_dev_start()
556 aw88261_dev_pwd(aw_dev, false); in aw88261_dev_start()
559 ret = aw88261_dev_check_syspll(aw_dev); in aw88261_dev_start()
561 dev_err(aw_dev->dev, "pll check failed cannot start"); in aw88261_dev_start()
566 aw88261_dev_amppd(aw_dev, false); in aw88261_dev_start()
570 ret = aw88261_dev_check_sysst(aw_dev); in aw88261_dev_start()
572 dev_err(aw_dev->dev, "sysst check failed"); in aw88261_dev_start()
577 aw88261_dev_i2s_tx_enable(aw_dev, true); in aw88261_dev_start()
580 aw88261_dev_amppd(aw_dev, true); in aw88261_dev_start()
585 aw88261_dev_uls_hmute(aw_dev, false); in aw88261_dev_start()
589 aw88261_dev_mute(aw_dev, false); in aw88261_dev_start()
592 aw88261_dev_clear_int_status(aw_dev); in aw88261_dev_start()
593 aw_dev->status = AW88261_DEV_PW_ON; in aw88261_dev_start()
598 aw88261_dev_i2s_tx_enable(aw_dev, false); in aw88261_dev_start()
599 aw88261_dev_clear_int_status(aw_dev); in aw88261_dev_start()
600 aw88261_dev_amppd(aw_dev, true); in aw88261_dev_start()
602 aw88261_dev_pwd(aw_dev, true); in aw88261_dev_start()
603 aw_dev->status = AW88261_DEV_PW_OFF; in aw88261_dev_start()
608 static int aw88261_dev_stop(struct aw_device *aw_dev) in aw88261_dev_stop() argument
610 if (aw_dev->status == AW88261_DEV_PW_OFF) { in aw88261_dev_stop()
611 dev_info(aw_dev->dev, "already power off"); in aw88261_dev_stop()
615 aw_dev->status = AW88261_DEV_PW_OFF; in aw88261_dev_stop()
618 aw88261_dev_clear_int_status(aw_dev); in aw88261_dev_stop()
620 aw88261_dev_uls_hmute(aw_dev, true); in aw88261_dev_stop()
622 aw88261_dev_mute(aw_dev, true); in aw88261_dev_stop()
625 aw88261_dev_i2s_tx_enable(aw_dev, false); in aw88261_dev_stop()
629 aw88261_dev_amppd(aw_dev, true); in aw88261_dev_stop()
632 aw88261_dev_pwd(aw_dev, true); in aw88261_dev_stop()
639 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_reg_update() local
643 ret = regmap_write(aw_dev->regmap, in aw88261_reg_update()
652 if (aw_dev->prof_cur != aw_dev->prof_index) { in aw88261_reg_update()
661 aw_dev->prof_cur = aw_dev->prof_index; in aw88261_reg_update()
739 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_get_fade_in_time() local
741 ucontrol->value.integer.value[0] = aw_dev->fade_in_time; in aw88261_get_fade_in_time()
753 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_set_fade_in_time() local
761 if (time != aw_dev->fade_in_time) { in aw88261_set_fade_in_time()
762 aw_dev->fade_in_time = time; in aw88261_set_fade_in_time()
774 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_get_fade_out_time() local
776 ucontrol->value.integer.value[0] = aw_dev->fade_out_time; in aw88261_get_fade_out_time()
788 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_set_fade_out_time() local
795 if (time != aw_dev->fade_out_time) { in aw88261_set_fade_out_time()
796 aw_dev->fade_out_time = time; in aw88261_set_fade_out_time()
803 static int aw88261_dev_set_profile_index(struct aw_device *aw_dev, int index) in aw88261_dev_set_profile_index() argument
806 if ((index >= aw_dev->prof_info.count) || (index < 0)) in aw88261_dev_set_profile_index()
809 if (aw_dev->prof_index == index) in aw88261_dev_set_profile_index()
812 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()
1179 struct aw_device *aw_dev = aw88261->aw_pa; in aw88261_parse_channel_dt() local
1180 struct device_node *np = aw_dev->dev->of_node; in aw88261_parse_channel_dt()
1186 aw_dev->channel = channel_value; in aw88261_parse_channel_dt()
1191 struct aw_device *aw_dev; in aw88261_init() local
1208 aw_dev = devm_kzalloc(&i2c->dev, sizeof(*aw_dev), GFP_KERNEL); in aw88261_init()
1209 if (!aw_dev) in aw88261_init()
1212 (*aw88261)->aw_pa = aw_dev; in aw88261_init()
1213 aw_dev->i2c = i2c; in aw88261_init()
1214 aw_dev->regmap = regmap; in aw88261_init()
1215 aw_dev->dev = &i2c->dev; in aw88261_init()
1216 aw_dev->chip_id = AW88261_CHIP_ID; in aw88261_init()
1217 aw_dev->acf = NULL; in aw88261_init()
1218 aw_dev->prof_info.prof_desc = NULL; in aw88261_init()
1219 aw_dev->prof_info.count = 0; in aw88261_init()
1220 aw_dev->prof_info.prof_type = AW88395_DEV_NONE_TYPE_ID; in aw88261_init()
1221 aw_dev->channel = 0; in aw88261_init()
1222 aw_dev->fw_status = AW88261_DEV_FW_FAILED; in aw88261_init()
1223 aw_dev->fade_step = AW88261_VOLUME_STEP_DB; in aw88261_init()
1224 aw_dev->volume_desc.ctl_volume = AW88261_VOL_DEFAULT_VALUE; in aw88261_init()
1225 aw_dev->volume_desc.mute_volume = AW88261_MUTE_VOL; in aw88261_init()