Lines Matching refs:aw87xxx

86 static int aw87xxx_update_off_prof(struct aw87xxx *aw87xxx, char *profile)  in aw87xxx_update_off_prof()  argument
91 struct aw_device *aw_dev = &aw87xxx->aw_dev; in aw87xxx_update_off_prof()
93 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_update_off_prof()
95 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_update_off_prof()
97 aw_monitor_stop(&aw87xxx->monitor); in aw87xxx_update_off_prof()
99 prof_desc = aw_acf_get_prof_desc_form_name(aw87xxx->dev, &aw87xxx->acf_info, profile); in aw87xxx_update_off_prof()
108 AW_DEV_LOGD(aw87xxx->dev, "get profile[%s] data len [%d]", in aw87xxx_update_off_prof()
112 AW_DEV_LOGI(aw87xxx->dev, "profile[%s] has already load ", profile); in aw87xxx_update_off_prof()
117 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", profile); in aw87xxx_update_off_prof()
123 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", profile); in aw87xxx_update_off_prof()
129 aw87xxx->current_profile = prof_desc->prof_name; in aw87xxx_update_off_prof()
130 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_update_off_prof()
136 aw_dev_hw_pwr_ctrl(&aw87xxx->aw_dev, false); in aw87xxx_update_off_prof()
137 aw87xxx->current_profile = aw87xxx->prof_off_name; in aw87xxx_update_off_prof()
138 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_update_off_prof()
142 int aw87xxx_update_profile(struct aw87xxx *aw87xxx, char *profile) in aw87xxx_update_profile() argument
146 struct aw_prof_info *prof_info = &aw87xxx->acf_info.prof_info; in aw87xxx_update_profile()
148 struct aw_device *aw_dev = &aw87xxx->aw_dev; in aw87xxx_update_profile()
150 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_update_profile()
153 AW_DEV_LOGE(aw87xxx->dev, "profile_cfg not load"); in aw87xxx_update_profile()
157 if (0 == strncmp(profile, aw87xxx->prof_off_name, AW_PROFILE_STR_MAX)) in aw87xxx_update_profile()
158 return aw87xxx_update_off_prof(aw87xxx, profile); in aw87xxx_update_profile()
160 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_update_profile()
162 prof_desc = aw_acf_get_prof_desc_form_name(aw87xxx->dev, &aw87xxx->acf_info, profile); in aw87xxx_update_profile()
164 AW_DEV_LOGE(aw87xxx->dev, "not found [%s] parameter", profile); in aw87xxx_update_profile()
165 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_update_profile()
170 AW_DEV_LOGE(aw87xxx->dev, "not found data container"); in aw87xxx_update_profile()
171 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_update_profile()
176 AW_DEV_LOGD(aw87xxx->dev, "get profile[%s] data len [%d]", in aw87xxx_update_profile()
179 aw_monitor_stop(&aw87xxx->monitor); in aw87xxx_update_profile()
184 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", in aw87xxx_update_profile()
186 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_update_profile()
187 return aw87xxx_update_off_prof(aw87xxx, aw87xxx->prof_off_name); in aw87xxx_update_profile()
192 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", in aw87xxx_update_profile()
194 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_update_profile()
195 return aw87xxx_update_off_prof(aw87xxx, aw87xxx->prof_off_name); in aw87xxx_update_profile()
199 aw87xxx->current_profile = prof_desc->prof_name; in aw87xxx_update_profile()
200 aw_monitor_start(&aw87xxx->monitor); in aw87xxx_update_profile()
201 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_update_profile()
203 AW_DEV_LOGD(aw87xxx->dev, "load profile[%s] succeed", profile); in aw87xxx_update_profile()
211 struct aw87xxx *aw87xxx = NULL; in aw87xxx_show_current_profile() local
214 aw87xxx = list_entry(pos, struct aw87xxx, list); in aw87xxx_show_current_profile()
215 if (aw87xxx == NULL) { in aw87xxx_show_current_profile()
220 if (aw87xxx->dev_index == dev_index) { in aw87xxx_show_current_profile()
221 AW_DEV_LOGI(aw87xxx->dev, "current profile is [%s]", in aw87xxx_show_current_profile()
222 aw87xxx->current_profile); in aw87xxx_show_current_profile()
223 return aw87xxx->current_profile; in aw87xxx_show_current_profile()
235 struct aw87xxx *aw87xxx = NULL; in aw87xxx_set_profile() local
238 aw87xxx = list_entry(pos, struct aw87xxx, list); in aw87xxx_set_profile()
239 if (aw87xxx == NULL) { in aw87xxx_set_profile()
244 if (profile && aw87xxx->dev_index == dev_index) in aw87xxx_set_profile()
245 return aw87xxx_update_profile(aw87xxx, profile); in aw87xxx_set_profile()
258 static int aw87xxx_esd_update_off_prof(struct aw87xxx *aw87xxx, char *profile) in aw87xxx_esd_update_off_prof() argument
263 struct aw_device *aw_dev = &aw87xxx->aw_dev; in aw87xxx_esd_update_off_prof()
265 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_esd_update_off_prof()
266 prof_desc = aw_acf_get_prof_desc_form_name(aw87xxx->dev, &aw87xxx->acf_info, profile); in aw87xxx_esd_update_off_prof()
274 AW_DEV_LOGD(aw87xxx->dev, "get profile[%s] data len [%d]", in aw87xxx_esd_update_off_prof()
278 AW_DEV_LOGI(aw87xxx->dev, "profile[%s] has already load ", profile); in aw87xxx_esd_update_off_prof()
283 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", profile); in aw87xxx_esd_update_off_prof()
289 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", profile); in aw87xxx_esd_update_off_prof()
295 aw87xxx->current_profile = prof_desc->prof_name; in aw87xxx_esd_update_off_prof()
300 aw_dev_hw_pwr_ctrl(&aw87xxx->aw_dev, false); in aw87xxx_esd_update_off_prof()
301 aw87xxx->current_profile = aw87xxx->prof_off_name; in aw87xxx_esd_update_off_prof()
305 int aw87xxx_esd_update_profile(struct aw87xxx *aw87xxx, char *profile) in aw87xxx_esd_update_profile() argument
309 struct aw_prof_info *prof_info = &aw87xxx->acf_info.prof_info; in aw87xxx_esd_update_profile()
311 struct aw_device *aw_dev = &aw87xxx->aw_dev; in aw87xxx_esd_update_profile()
313 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_esd_update_profile()
316 AW_DEV_LOGE(aw87xxx->dev, "profile_cfg not load"); in aw87xxx_esd_update_profile()
320 if (0 == strncmp(profile, aw87xxx->prof_off_name, AW_PROFILE_STR_MAX)) in aw87xxx_esd_update_profile()
321 return aw87xxx_esd_update_off_prof(aw87xxx, profile); in aw87xxx_esd_update_profile()
323 prof_desc = aw_acf_get_prof_desc_form_name(aw87xxx->dev, &aw87xxx->acf_info, in aw87xxx_esd_update_profile()
326 AW_DEV_LOGE(aw87xxx->dev, "not found [%s] parameter", profile); in aw87xxx_esd_update_profile()
331 AW_DEV_LOGE(aw87xxx->dev, "not found data container"); in aw87xxx_esd_update_profile()
336 AW_DEV_LOGD(aw87xxx->dev, "get profile[%s] data len [%d]", in aw87xxx_esd_update_profile()
342 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", in aw87xxx_esd_update_profile()
349 AW_DEV_LOGE(aw87xxx->dev, "load profile[%s] failed ", in aw87xxx_esd_update_profile()
354 aw87xxx->current_profile = prof_desc->prof_name; in aw87xxx_esd_update_profile()
355 AW_DEV_LOGD(aw87xxx->dev, "recover load profile[%s] succeed", profile); in aw87xxx_esd_update_profile()
371 struct aw87xxx *aw87xxx = (struct aw87xxx *)kcontrol->private_value; in aw87xxx_profile_switch_info() local
373 if (aw87xxx == NULL) { in aw87xxx_profile_switch_info()
382 count = aw_acf_get_profile_count(aw87xxx->dev, &aw87xxx->acf_info); in aw87xxx_profile_switch_info()
385 AW_DEV_LOGE(aw87xxx->dev, "get count[%d] failed", count); in aw87xxx_profile_switch_info()
395 profile_name = aw_acf_get_prof_name_form_index(aw87xxx->dev, in aw87xxx_profile_switch_info()
396 &aw87xxx->acf_info, count); in aw87xxx_profile_switch_info()
414 struct aw87xxx *aw87xxx = (struct aw87xxx *)kcontrol->private_value; in aw87xxx_profile_switch_put() local
415 struct acf_bin_info *acf_info = &aw87xxx->acf_info; in aw87xxx_profile_switch_put()
417 if (aw87xxx == NULL) { in aw87xxx_profile_switch_put()
422 profile_name = aw_acf_get_prof_name_form_index(aw87xxx->dev, acf_info, index); in aw87xxx_profile_switch_put()
424 AW_DEV_LOGE(aw87xxx->dev, "not found profile name,index=[%d]", in aw87xxx_profile_switch_put()
429 AW_DEV_LOGI(aw87xxx->dev, "set profile [%s]", profile_name); in aw87xxx_profile_switch_put()
431 ret = aw87xxx_update_profile(aw87xxx, profile_name); in aw87xxx_profile_switch_put()
433 AW_DEV_LOGE(aw87xxx->dev, "set dev_index[%d] profile failed, profile = %s", in aw87xxx_profile_switch_put()
434 aw87xxx->dev_index, profile_name); in aw87xxx_profile_switch_put()
446 struct aw87xxx *aw87xxx = (struct aw87xxx *)kcontrol->private_value; in aw87xxx_profile_switch_get() local
448 if (aw87xxx == NULL) { in aw87xxx_profile_switch_get()
453 if (!aw87xxx->current_profile) { in aw87xxx_profile_switch_get()
454 AW_DEV_LOGE(aw87xxx->dev, "profile not init"); in aw87xxx_profile_switch_get()
458 profile = aw87xxx->current_profile; in aw87xxx_profile_switch_get()
459 AW_DEV_LOGI(aw87xxx->dev, "current profile:[%s]", in aw87xxx_profile_switch_get()
460 aw87xxx->current_profile); in aw87xxx_profile_switch_get()
463 index = aw_acf_get_prof_index_form_name(aw87xxx->dev, in aw87xxx_profile_switch_get()
464 &aw87xxx->acf_info, aw87xxx->current_profile); in aw87xxx_profile_switch_get()
466 AW_DEV_LOGE(aw87xxx->dev, "get profile index failed"); in aw87xxx_profile_switch_get()
491 struct aw87xxx *aw87xxx = (struct aw87xxx *)kcontrol->private_value; in aw87xxxx_vmax_get() local
493 if (aw87xxx == NULL) { in aw87xxxx_vmax_get()
498 ret = aw_monitor_no_dsp_get_vmax(&aw87xxx->monitor, &vmax_val); in aw87xxxx_vmax_get()
503 AW_DEV_LOGI(aw87xxx->dev, "get vmax = [0x%x]", vmax_val); in aw87xxxx_vmax_get()
508 static int aw87xxx_kcontrol_dynamic_create(struct aw87xxx *aw87xxx, in aw87xxx_kcontrol_dynamic_create() argument
517 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_kcontrol_dynamic_create()
518 aw87xxx->codec = soc_codec; in aw87xxx_kcontrol_dynamic_create()
520 aw87xxx_kcontrol = devm_kzalloc(aw87xxx->dev, in aw87xxx_kcontrol_dynamic_create()
524 AW_DEV_LOGE(aw87xxx->dev, "aw87xxx_kcontrol devm_kzalloc failed"); in aw87xxx_kcontrol_dynamic_create()
528 kctl_name[0] = devm_kzalloc(aw87xxx->dev, AW_NAME_BUF_MAX, in aw87xxx_kcontrol_dynamic_create()
534 aw87xxx->dev_index); in aw87xxx_kcontrol_dynamic_create()
541 aw87xxx_kcontrol[0].private_value = (unsigned long)aw87xxx; in aw87xxx_kcontrol_dynamic_create()
543 kctl_name[1] = devm_kzalloc(aw87xxx->codec->dev, AW_NAME_BUF_MAX, in aw87xxx_kcontrol_dynamic_create()
549 aw87xxx->dev_index); in aw87xxx_kcontrol_dynamic_create()
556 aw87xxx_kcontrol[1].private_value = (unsigned long)aw87xxx; in aw87xxx_kcontrol_dynamic_create()
558 ret = aw_componet_codec_ops.add_codec_controls(aw87xxx->codec, in aw87xxx_kcontrol_dynamic_create()
561 AW_DEV_LOGE(aw87xxx->dev, "add codec controls failed, ret = %d", in aw87xxx_kcontrol_dynamic_create()
566 AW_DEV_LOGI(aw87xxx->dev, "add codec controls[%s,%s]", in aw87xxx_kcontrol_dynamic_create()
581 struct aw87xxx *aw87xxx = NULL; in aw87xxx_add_codec_controls() local
585 aw87xxx = list_entry(pos, struct aw87xxx, list); in aw87xxx_add_codec_controls()
586 if (aw87xxx == NULL) { in aw87xxx_add_codec_controls()
591 ret = aw87xxx_kcontrol_dynamic_create(aw87xxx, codec); in aw87xxx_add_codec_controls()
606 static void aw87xxx_fw_cfg_free(struct aw87xxx *aw87xxx) in aw87xxx_fw_cfg_free() argument
608 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_fw_cfg_free()
609 aw_acf_profile_free(aw87xxx->dev, &aw87xxx->acf_info); in aw87xxx_fw_cfg_free()
610 aw_monitor_cfg_free(&aw87xxx->monitor); in aw87xxx_fw_cfg_free()
613 static int aw87xxx_init_default_prof(struct aw87xxx *aw87xxx) in aw87xxx_init_default_prof() argument
617 profile = aw_acf_get_prof_off_name(aw87xxx->dev, &aw87xxx->acf_info); in aw87xxx_init_default_prof()
619 AW_DEV_LOGE(aw87xxx->dev, "get profile off name failed"); in aw87xxx_init_default_prof()
623 snprintf(aw87xxx->prof_off_name, AW_PROFILE_STR_MAX, "%s", profile); in aw87xxx_init_default_prof()
624 aw87xxx->current_profile = profile; in aw87xxx_init_default_prof()
625 AW_DEV_LOGI(aw87xxx->dev, "init profile name [%s]", in aw87xxx_init_default_prof()
626 aw87xxx->current_profile); in aw87xxx_init_default_prof()
631 static void aw87xxx_fw_load_retry(struct aw87xxx *aw87xxx) in aw87xxx_fw_load_retry() argument
633 struct acf_bin_info *acf_info = &aw87xxx->acf_info; in aw87xxx_fw_load_retry()
636 AW_DEV_LOGD(aw87xxx->dev, "failed to read [%s]", in aw87xxx_fw_load_retry()
637 aw87xxx->fw_name); in aw87xxx_fw_load_retry()
640 AW_DEV_LOGD(aw87xxx->dev, in aw87xxx_fw_load_retry()
642 schedule_delayed_work(&aw87xxx->fw_load_work, in aw87xxx_fw_load_retry()
646 AW_DEV_LOGE(aw87xxx->dev, in aw87xxx_fw_load_retry()
656 struct aw87xxx *aw87xxx = context; in aw87xxx_fw_load() local
657 struct acf_bin_info *acf_info = &aw87xxx->acf_info; in aw87xxx_fw_load()
659 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_fw_load()
662 aw87xxx_fw_load_retry(aw87xxx); in aw87xxx_fw_load()
666 AW_DEV_LOGD(aw87xxx->dev, "loaded %s - size: %ld", in aw87xxx_fw_load()
667 aw87xxx->fw_name, (u_long)(fw ? fw->size : 0)); in aw87xxx_fw_load()
669 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_fw_load()
672 AW_DEV_LOGE(aw87xxx->dev, "fw_data kzalloc memory failed"); in aw87xxx_fw_load()
679 ret = aw_acf_parse(aw87xxx->dev, &aw87xxx->acf_info); in aw87xxx_fw_load()
681 AW_DEV_LOGE(aw87xxx->dev, "fw_data parse failed"); in aw87xxx_fw_load()
685 ret = aw87xxx_init_default_prof(aw87xxx); in aw87xxx_fw_load()
687 aw87xxx_fw_cfg_free(aw87xxx); in aw87xxx_fw_load()
691 AW_DEV_LOGI(aw87xxx->dev, "acf parse succeed"); in aw87xxx_fw_load()
692 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_fw_load()
699 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_fw_load()
704 struct aw87xxx *aw87xxx = container_of(work, in aw87xxx_fw_load_work_routine() local
705 struct aw87xxx, fw_load_work.work); in aw87xxx_fw_load_work_routine()
706 struct aw_prof_info *prof_info = &aw87xxx->acf_info.prof_info; in aw87xxx_fw_load_work_routine()
708 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_fw_load_work_routine()
714 ret = request_firmware(&fw, aw87xxx->fw_name, aw87xxx->dev); in aw87xxx_fw_load_work_routine()
716 AW_DEV_LOGD(aw87xxx->dev, "loader firmware %s success\n", aw87xxx->fw_name); in aw87xxx_fw_load_work_routine()
717 aw87xxx_fw_load(fw, aw87xxx); in aw87xxx_fw_load_work_routine()
722 static void aw87xxx_fw_load_init(struct aw87xxx *aw87xxx) in aw87xxx_fw_load_init() argument
729 AW_DEV_LOGI(aw87xxx->dev, "enter"); in aw87xxx_fw_load_init()
730 snprintf(aw87xxx->fw_name, AW87XXX_FW_NAME_MAX, "%s", AW87XXX_FW_BIN_NAME); in aw87xxx_fw_load_init()
731 aw_acf_init(&aw87xxx->aw_dev, &aw87xxx->acf_info, aw87xxx->dev_index); in aw87xxx_fw_load_init()
733 INIT_DELAYED_WORK(&aw87xxx->fw_load_work, aw87xxx_fw_load_work_routine); in aw87xxx_fw_load_init()
734 schedule_delayed_work(&aw87xxx->fw_load_work, in aw87xxx_fw_load_init()
750 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_get_reg() local
751 struct aw_device *aw_dev = &aw87xxx->aw_dev; in aw87xxx_attr_get_reg()
753 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_attr_get_reg()
757 ret = aw_dev_i2c_read_byte(&aw87xxx->aw_dev, i, &reg_val); in aw87xxx_attr_get_reg()
761 AW_DEV_LOGE(aw87xxx->dev, "read reg [0x%x] failed", i); in aw87xxx_attr_get_reg()
765 AW_DEV_LOGD(aw87xxx->dev, "reg:0x%02X=0x%02X", in aw87xxx_attr_get_reg()
769 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_attr_get_reg()
780 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_set_reg() local
782 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_attr_set_reg()
784 if (databuf[0] >= aw87xxx->aw_dev.reg_max_addr) { in aw87xxx_attr_set_reg()
785 AW_DEV_LOGE(aw87xxx->dev, "set reg[0x%x] error,is out of reg_addr_max[0x%x]", in aw87xxx_attr_set_reg()
786 databuf[0], aw87xxx->aw_dev.reg_max_addr); in aw87xxx_attr_set_reg()
787 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_attr_set_reg()
791 ret = aw_dev_i2c_write_byte(&aw87xxx->aw_dev, in aw87xxx_attr_set_reg()
794 AW_DEV_LOGE(aw87xxx->dev, "set [0x%x]=0x%x failed", in aw87xxx_attr_set_reg()
797 AW_DEV_LOGD(aw87xxx->dev, "set [0x%x]=0x%x succeed", in aw87xxx_attr_set_reg()
800 AW_DEV_LOGE(aw87xxx->dev, "i2c write cmd input error"); in aw87xxx_attr_set_reg()
802 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_attr_set_reg()
812 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_get_profile() local
813 struct aw_prof_info *prof_info = &aw87xxx->acf_info.prof_info; in aw87xxx_attr_get_profile()
821 AW_DEV_LOGI(aw87xxx->dev, "current profile:[%s]", aw87xxx->current_profile); in aw87xxx_attr_get_profile()
824 if (!strncmp(aw87xxx->current_profile, prof_info->prof_name_list[i], in aw87xxx_attr_get_profile()
842 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_set_profile() local
845 AW_DEV_LOGD(aw87xxx->dev, "set profile [%s]", profile); in aw87xxx_attr_set_profile()
846 ret = aw87xxx_update_profile(aw87xxx, profile); in aw87xxx_attr_set_profile()
848 AW_DEV_LOGE(aw87xxx->dev, "set profile[%s] failed", in aw87xxx_attr_set_profile()
861 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_get_hwen() local
862 int hwen = aw87xxx->aw_dev.hwen_status; in aw87xxx_attr_get_hwen()
880 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_set_hwen() local
884 AW_DEV_LOGE(aw87xxx->dev, "fail to channelge str to int"); in aw87xxx_attr_set_hwen()
888 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_attr_set_hwen()
890 aw_dev_hw_pwr_ctrl(&aw87xxx->aw_dev, false); /*OFF*/ in aw87xxx_attr_set_hwen()
892 aw_dev_hw_pwr_ctrl(&aw87xxx->aw_dev, true); /*ON*/ in aw87xxx_attr_set_hwen()
894 AW_DEV_LOGE(aw87xxx->dev, "input [%d] error, hwen_on=[%d],hwen_off=[%d]", in aw87xxx_attr_set_hwen()
896 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_attr_set_hwen()
900 int aw87xxx_awrw_write(struct aw87xxx *aw87xxx, in aw87xxx_awrw_write() argument
909 struct aw_i2c_packet *packet = &aw87xxx->i2c_packet; in aw87xxx_awrw_write()
911 AW_DEV_LOGD(aw87xxx->dev, "enter"); in aw87xxx_awrw_write()
918 AW_DEV_LOGI(aw87xxx->dev, "buf_len = %d,reg_num = %d", buf_len, packet->reg_num); in aw87xxx_awrw_write()
921 AW_DEV_LOGE(aw87xxx->dev, "alloc memory failed"); in aw87xxx_awrw_write()
929 AW_DEV_LOGD(aw87xxx->dev, "reg_addr: 0x%02x", data_buf[0]); in aw87xxx_awrw_write()
936 AW_DEV_LOGE(aw87xxx->dev, "sscanf failed,ret=%d", ret); in aw87xxx_awrw_write()
940 AW_DEV_LOGD(aw87xxx->dev, "[%d] : 0x%02x", i, reg_data[i]); in aw87xxx_awrw_write()
943 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_awrw_write()
944 ret = i2c_master_send(aw87xxx->aw_dev.i2c, data_buf, buf_len); in aw87xxx_awrw_write()
946 AW_DEV_LOGE(aw87xxx->dev, "write failed"); in aw87xxx_awrw_write()
949 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_awrw_write()
952 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_awrw_write()
957 AW_DEV_LOGD(aw87xxx->dev, "down"); in aw87xxx_awrw_write()
961 static int aw87xxx_awrw_data_check(struct aw87xxx *aw87xxx, in aw87xxx_awrw_data_check() argument
964 struct aw_i2c_packet *packet = &aw87xxx->i2c_packet; in aw87xxx_awrw_data_check()
971 AW_DEV_LOGE(aw87xxx->dev, "addr_bytes [%d] or data_bytes [%d] unsupport", in aw87xxx_awrw_data_check()
986 AW_DEV_LOGE(aw87xxx->dev, "data_len checkfailed,requeset data_len [%d],actaul data_len [%d]", in aw87xxx_awrw_data_check()
996 static int aw87xxx_awrw_parse_buf(struct aw87xxx *aw87xxx, in aw87xxx_awrw_parse_buf() argument
1000 struct aw_i2c_packet *packet = &aw87xxx->i2c_packet; in aw87xxx_awrw_parse_buf()
1011 ret = aw87xxx_awrw_data_check(aw87xxx, data, count); in aw87xxx_awrw_parse_buf()
1024 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_awrw_store() local
1025 struct aw_i2c_packet *packet = &aw87xxx->i2c_packet; in aw87xxx_attr_awrw_store()
1030 AW_DEV_LOGE(aw87xxx->dev, "data count too smaller, please check write format"); in aw87xxx_attr_awrw_store()
1031 AW_DEV_LOGE(aw87xxx->dev, "string %s,count=%ld", in aw87xxx_attr_awrw_store()
1036 AW_DEV_LOGI(aw87xxx->dev, "string:[%s],count=%ld", buf, (u_long)count); in aw87xxx_attr_awrw_store()
1037 ret = aw87xxx_awrw_parse_buf(aw87xxx, buf, count, &wr_status); in aw87xxx_attr_awrw_store()
1039 AW_DEV_LOGE(aw87xxx->dev, "can not parse string"); in aw87xxx_attr_awrw_store()
1044 ret = aw87xxx_awrw_write(aw87xxx, buf, count); in aw87xxx_attr_awrw_store()
1049 AW_DEV_LOGI(aw87xxx->dev, "read_cmd:reg_addr[0x%02x], reg_num[%d]", in aw87xxx_attr_awrw_store()
1052 AW_DEV_LOGE(aw87xxx->dev, "please check str format, unsupport read_write_status: %d", in aw87xxx_attr_awrw_store()
1063 struct aw87xxx *aw87xxx = dev_get_drvdata(dev); in aw87xxx_attr_awrw_show() local
1064 struct aw_i2c_packet *packet = &aw87xxx->i2c_packet; in aw87xxx_attr_awrw_show()
1071 AW_DEV_LOGE(aw87xxx->dev, "please write read cmd first"); in aw87xxx_attr_awrw_show()
1078 AW_DEV_LOGE(aw87xxx->dev, "memory alloc failed"); in aw87xxx_attr_awrw_show()
1083 mutex_lock(&aw87xxx->reg_lock); in aw87xxx_attr_awrw_show()
1084 ret = aw_dev_i2c_read_msg(&aw87xxx->aw_dev, packet->reg_addr, in aw87xxx_attr_awrw_show()
1088 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_attr_awrw_show()
1091 mutex_unlock(&aw87xxx->reg_lock); in aw87xxx_attr_awrw_show()
1093 AW_DEV_LOGI(aw87xxx->dev, "reg_addr 0x%02x, reg_num %d", in aw87xxx_attr_awrw_show()
1099 AW_DEV_LOGI(aw87xxx->dev, "0x%02x", reg_data[i]); in aw87xxx_attr_awrw_show()
1153 int aw87xxx_dtsi_dev_index_check(struct aw87xxx *cur_aw87xxx) in aw87xxx_dtsi_dev_index_check()
1156 struct aw87xxx *list_aw87xxx = NULL; in aw87xxx_dtsi_dev_index_check()
1159 list_aw87xxx = list_entry(pos, struct aw87xxx, list); in aw87xxx_dtsi_dev_index_check()
1172 static int aw87xxx_dtsi_parse(struct aw87xxx *aw87xxx, in aw87xxx_dtsi_parse() argument
1180 AW_DEV_LOGI(aw87xxx->dev, "dev_index parse failed, user default[%d], ret=%d", in aw87xxx_dtsi_parse()
1182 aw87xxx->dev_index = g_aw87xxx_dev_cnt; in aw87xxx_dtsi_parse()
1184 aw87xxx->dev_index = dev_index; in aw87xxx_dtsi_parse()
1185 AW_DEV_LOGI(aw87xxx->dev, "parse dev_index=[%d]", in aw87xxx_dtsi_parse()
1186 aw87xxx->dev_index); in aw87xxx_dtsi_parse()
1189 ret = aw87xxx_dtsi_dev_index_check(aw87xxx); in aw87xxx_dtsi_parse()
1195 AW_DEV_LOGI(aw87xxx->dev, "no reset gpio provided, hardware reset unavailable"); in aw87xxx_dtsi_parse()
1196 aw87xxx->aw_dev.rst_gpio = AW_NO_RESET_GPIO; in aw87xxx_dtsi_parse()
1197 aw87xxx->aw_dev.hwen_status = AW_DEV_HWEN_INVALID; in aw87xxx_dtsi_parse()
1199 aw87xxx->aw_dev.rst_gpio = ret; in aw87xxx_dtsi_parse()
1200 aw87xxx->aw_dev.hwen_status = AW_DEV_HWEN_OFF; in aw87xxx_dtsi_parse()
1201 AW_DEV_LOGI(aw87xxx->dev, "reset gpio[%d] parse succeed", ret); in aw87xxx_dtsi_parse()
1202 if (gpio_is_valid(aw87xxx->aw_dev.rst_gpio)) { in aw87xxx_dtsi_parse()
1203 ret = devm_gpio_request_one(aw87xxx->dev, in aw87xxx_dtsi_parse()
1204 aw87xxx->aw_dev.rst_gpio, in aw87xxx_dtsi_parse()
1207 AW_DEV_LOGE(aw87xxx->dev, "reset request failed"); in aw87xxx_dtsi_parse()
1217 AW_DEV_LOGI(aw87xxx->dev, "no reset shared gpio provided, hardware reset unavailable"); in aw87xxx_dtsi_parse()
1218 aw87xxx->aw_dev.rst_shared_gpio = AW_NO_RESET_GPIO; in aw87xxx_dtsi_parse()
1220 aw87xxx->aw_dev.rst_shared_gpio = ret; in aw87xxx_dtsi_parse()
1221 AW_DEV_LOGI(aw87xxx->dev, "reset shared gpio[%d] parse succeed", ret); in aw87xxx_dtsi_parse()
1222 if (gpio_is_valid(aw87xxx->aw_dev.rst_shared_gpio)) { in aw87xxx_dtsi_parse()
1223 ret = devm_gpio_request_one(aw87xxx->dev, in aw87xxx_dtsi_parse()
1224 aw87xxx->aw_dev.rst_shared_gpio, in aw87xxx_dtsi_parse()
1227 AW_DEV_LOGE(aw87xxx->dev, "aw87xxx_reset-shared reset request failed"); in aw87xxx_dtsi_parse()
1231 gpio_set_value_cansleep(aw87xxx->aw_dev.rst_shared_gpio, AW_GPIO_HIGHT_LEVEL); in aw87xxx_dtsi_parse()
1237 static struct aw87xxx *aw87xxx_malloc_init(struct i2c_client *client) in aw87xxx_malloc_init()
1239 struct aw87xxx *aw87xxx = NULL; in aw87xxx_malloc_init() local
1241 aw87xxx = devm_kzalloc(&client->dev, sizeof(struct aw87xxx), in aw87xxx_malloc_init()
1243 if (aw87xxx == NULL) { in aw87xxx_malloc_init()
1247 memset(aw87xxx, 0, sizeof(struct aw87xxx)); in aw87xxx_malloc_init()
1249 aw87xxx->dev = &client->dev; in aw87xxx_malloc_init()
1250 aw87xxx->aw_dev.dev = &client->dev; in aw87xxx_malloc_init()
1251 aw87xxx->aw_dev.i2c_bus = client->adapter->nr; in aw87xxx_malloc_init()
1252 aw87xxx->aw_dev.i2c_addr = client->addr; in aw87xxx_malloc_init()
1253 aw87xxx->aw_dev.i2c = client; in aw87xxx_malloc_init()
1254 aw87xxx->aw_dev.hwen_status = false; in aw87xxx_malloc_init()
1255 aw87xxx->aw_dev.reg_access = NULL; in aw87xxx_malloc_init()
1256 aw87xxx->aw_dev.hwen_status = AW_DEV_HWEN_INVALID; in aw87xxx_malloc_init()
1257 aw87xxx->off_bin_status = AW87XXX_NO_OFF_BIN; in aw87xxx_malloc_init()
1258 aw87xxx->codec = NULL; in aw87xxx_malloc_init()
1259 aw87xxx->current_profile = aw87xxx->prof_off_name; in aw87xxx_malloc_init()
1261 mutex_init(&aw87xxx->reg_lock); in aw87xxx_malloc_init()
1264 return aw87xxx; in aw87xxx_malloc_init()
1269 struct aw87xxx *aw87xxx = dev_get_drvdata(component->dev); in aw87xxx_probe() local
1272 ret = aw87xxx_kcontrol_dynamic_create(aw87xxx, component); in aw87xxx_probe()
1289 struct aw87xxx *aw87xxx = NULL; in aw87xxx_i2c_probe() local
1299 aw87xxx = aw87xxx_malloc_init(client); in aw87xxx_i2c_probe()
1300 if (aw87xxx == NULL) in aw87xxx_i2c_probe()
1303 i2c_set_clientdata(client, aw87xxx); in aw87xxx_i2c_probe()
1306 ret = aw87xxx_dtsi_parse(aw87xxx, dev_node); in aw87xxx_i2c_probe()
1311 aw_dev_hw_pwr_ctrl(&aw87xxx->aw_dev, true); in aw87xxx_i2c_probe()
1314 ret = aw_dev_init(&aw87xxx->aw_dev); in aw87xxx_i2c_probe()
1318 ret = devm_snd_soc_register_component(aw87xxx->dev, &aw87xxx_component_driver, in aw87xxx_i2c_probe()
1321 dev_err(aw87xxx->dev, "%s() register codec error %d\n", in aw87xxx_i2c_probe()
1327 aw_dev_soft_reset(&aw87xxx->aw_dev); in aw87xxx_i2c_probe()
1330 aw_dev_hw_pwr_ctrl(&aw87xxx->aw_dev, false); in aw87xxx_i2c_probe()
1333 ret = sysfs_create_group(&aw87xxx->dev->kobj, &aw87xxx_attribute_group); in aw87xxx_i2c_probe()
1335 AW_DEV_LOGE(aw87xxx->dev, "failed to create sysfs nodes, will not allowed to use"); in aw87xxx_i2c_probe()
1338 aw87xxx_fw_load_init(aw87xxx); in aw87xxx_i2c_probe()
1341 aw_monitor_init(aw87xxx->dev, &aw87xxx->monitor, dev_node); in aw87xxx_i2c_probe()
1346 list_add(&aw87xxx->list, &g_aw87xxx_list); in aw87xxx_i2c_probe()
1349 AW_DEV_LOGI(aw87xxx->dev, "succeed"); in aw87xxx_i2c_probe()
1353 AW_DEV_LOGE(aw87xxx->dev, "pa init failed"); in aw87xxx_i2c_probe()
1359 struct aw87xxx *aw87xxx = i2c_get_clientdata(client); in aw87xxx_i2c_remove() local
1361 aw_monitor_exit(&aw87xxx->monitor); in aw87xxx_i2c_remove()
1364 sysfs_remove_group(&aw87xxx->dev->kobj, &aw87xxx_attribute_group); in aw87xxx_i2c_remove()
1366 aw87xxx_fw_cfg_free(aw87xxx); in aw87xxx_i2c_remove()
1370 list_del(&aw87xxx->list); in aw87xxx_i2c_remove()
1378 struct aw87xxx *aw87xxx = i2c_get_clientdata(client); in aw87xxx_i2c_shutdown() local
1383 aw87xxx_update_profile(aw87xxx, aw87xxx->prof_off_name); in aw87xxx_i2c_shutdown()