static ssize_t stage2_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int id; struct msdc_host *host; sscanf(attr->attr.name, "%d", &id); if (id >= HOST_MAX_NUM) { printk("[%s] id<%d> is bigger than HOST_MAX_NUM<%d>\n", __func__, id, HOST_MAX_NUM); return count; } host = mtk_msdc_host[id]; if(count > 2){ store_autok(&p_autok_predata[id], buf, count); // [FIXDONE] Hook the function to apply parameter to respective controller #ifdef AUTOK_THREAD p_autok_thread_data->host = host; p_autok_thread_data->stage = 2; p_autok_thread_data->p_autok_predata = &p_autok_predata[id]; p_autok_thread_data->log = autok_log_info; task = kthread_run(&autok_thread_func,(void *)(p_autok_thread_data),"autokp"); //autok_thread_func((void *)(p_autok_thread_data)); //wake_up_process(task); #endif #ifdef UT_TEST if(is_first_stage1 == 0) { // release host autok_release_host(host); #ifdef CONFIG_SDIOAUTOK_SUPPORT //mt_cpufreq_disable(0, false); #ifndef _DVFS_ENABLE_ mt_vcore_dvfs_disable_by_sdio(0, false); #else vcorefs_sdio_unlock_dvfs(0); #endif #endif #ifdef MTK_SDIO30_ONLINE_TUNING_SUPPORT atomic_set(&host->ot_work.autok_done, 1); atomic_set(&host->ot_work.ot_disable, 0); #endif // MTK_SDIO30_ONLINE_TUNING_SUPPORT is_first_stage1 = 1; } #endif } return count; }
static ssize_t stage1_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { char cur_name[DEVNAME_SIZE]=""; int test_len, cur_len; int i, j; int id; int select; struct msdc_host *host; //char *p_log; //id = 3; select = -1; sscanf(kobj->name, "%d", &id); if (id >= HOST_MAX_NUM) { printk("[%s] id<%d> is bigger than HOST_MAX_NUM<%d>\n", __func__, id, HOST_MAX_NUM); return count; } host = mtk_msdc_host[id]; sscanf(attr->attr.name, "%s", cur_name); for(i=0; i<TOTAL_STAGE1_NODE_COUNT; i++){ test_len = strlen(stage1_nodes[i]); cur_len = strlen(cur_name); if((test_len==cur_len) && (strncmp(stage1_nodes[i], cur_name, cur_len)==0)){ select = i; break; } } switch(select){ case VOLTAGE: sscanf(buf, "%u", &cur_voltage[id]); break; case PARAMS: memset(cur_name, 0, DEVNAME_SIZE); cur_name[0] = 1; cur_name[1] = E_AUTOK_PARM_MAX; memcpy(&cur_name[2], &cur_voltage[id], sizeof(unsigned int)); store_autok(&p_single_autok[id], cur_name, count); printk(KERN_ERR "[AUTOKD] Enter Store Autok"); printk(KERN_ERR "[AUTOKD] p_single_autok[%d].vol_count=%d", id, p_single_autok[id].vol_count); printk(KERN_ERR "[AUTOKD] p_single_autok[%d].param_count=%d", id, p_single_autok[id].param_count); for(i=0; i<p_single_autok[id].vol_count; i++){ printk(KERN_ERR "[AUTOKD] p_single_autok[%d].vol_list[%d]=%d", id, i, p_single_autok[id].vol_list[i]); } for(i=0; i<p_single_autok[id].vol_count; i++){ for(j=0; j<p_single_autok[id].param_count; j++) printk(KERN_ERR "[AUTOKD] p_single_autok[%d].ai_data[%d][%d]=%d", id, i, j, p_single_autok[id].ai_data[i][j].data.sel); } //[FIXDONE] Start to do autok alforithm; data is in p_single_autok #ifdef UT_TEST if(is_first_stage1 == 1) { // claim host #ifdef CONFIG_SDIOAUTOK_SUPPORT //mt_cpufreq_disable(0, true); //FIXME@CCJ mt_vcore_dvfs_disable_by_sdio(0, true); #endif #ifdef MTK_SDIO30_ONLINE_TUNING_SUPPORT atomic_set(&host->ot_work.ot_disable, 1); #endif // MTK_SDIO30_ONLINE_TUNING_SUPPORT autok_claim_host(host); is_first_stage1 = 0; } #endif #ifdef AUTOK_THREAD p_autok_thread_data->host = host; p_autok_thread_data->stage = 1; p_autok_thread_data->p_autok_predata = &p_single_autok[id]; p_autok_thread_data->log = autok_log_info; task = kthread_run(&autok_thread_func,(void *)(p_autok_thread_data),"autokp"); #endif break; case DONE: sscanf(buf, "%d", &i); p_autok_thread_data->is_autok_done[id] = (u8)i; break; case LOG: sscanf(buf, "%d", &i); if(is_full_log != i){ is_full_log = i; if(i==0){ debugfs_remove(autok_log_entry); //kfree(autok_log_info); }else{ autok_log_entry = debugfs_create_file("autok_log", 0660, NULL, NULL, &autok_log_fops); i_gid_write(autok_log_entry->d_inode, 1000); autok_log_info = (char*)kzalloc(LOG_SIZE, GFP_KERNEL); total_msg_size = 0;//rewind the counter to 0 when allocate new buffer } } break; default: break; } return count; }