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; }
int wait_sdio_autok_ready(void *data){ int i; int ret = 0; BOOTMODE btmod; struct mmc_host *mmc = (struct mmc_host*)data; struct msdc_host *host = NULL; int id; unsigned int vcore_uv = 0; int is_screen_off; btmod = get_boot_mode(); //printk("btmod = %d\n", btmod); atomic_set(&autok_is_abort, 0); if((vcorefs_is_95m_segment()) && (btmod == META_BOOT)) return 0; if (1/*(btmod!=META_BOOT)*/){ sdio_host_debug = 0; //host = mtk_msdc_host[id]; host = mmc_priv(mmc); id = host->id; #ifndef UT_TEST // claim host #ifdef CONFIG_SDIOAUTOK_SUPPORT //mt_cpufreq_disable(0, true); #ifndef _DVFS_ENABLE_ mt_vcore_dvfs_disable_by_sdio(0, true); #else // If it's screen off, sdio add suggest vol with LV is_screen_off = vcorefs_sdio_lock_dvfs(0); if(is_screen_off){ autok_add_suggest_vol(1000000); //DVFS Define 1.0v as LV } #endif if(is_sug_more_than_real(id)){ for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == id){ p_autok_thread_data->p_autok_progress[i].done = 0; break; } } } #endif #ifdef MTK_SDIO30_ONLINE_TUNING_SUPPORT atomic_set(&host->ot_work.ot_disable, 1); atomic_set(&host->ot_work.autok_done, 0); #endif // MTK_SDIO30_ONLINE_TUNING_SUPPORT autok_claim_host(host); #endif #ifdef AUTOK_THREAD for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == id && p_autok_thread_data->p_autok_progress[i].done == 1 && p_autok_thread_data->p_autok_progress[i].fail == 0) { vcore_uv = autok_get_current_vcore_offset(); msdc_autok_stg2_cal(host, &p_autok_predata[id], vcore_uv); break; } } if (i != HOST_MAX_NUM) goto EXIT_WAIT_AUTOK_READY; #endif for(i=0; i<HOST_MAX_NUM; i++){ if(p_autok_thread_data->p_autok_progress[i].host_id == -1 || p_autok_thread_data->p_autok_progress[i].host_id == id){ send_autok_uevent("s2_ready", host); init_completion(&p_autok_thread_data->autok_completion[i]); p_autok_thread_data->p_autok_progress[i].done = 0; p_autok_thread_data->p_autok_progress[i].fail = 0; p_autok_thread_data->p_autok_progress[i].host_id = id; wait_for_completion_interruptible(&p_autok_thread_data->autok_completion[i]); for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == id && p_autok_thread_data->p_autok_progress[i].fail == 1) { ret = -1; break; } } send_autok_uevent("s2_done", host); break; } } //reset_autok_cursor(0); EXIT_WAIT_AUTOK_READY: #ifndef UT_TEST // 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 #endif } return ret; }
int wait_sdio_autok_ready(void *data){ int i; int ret = 0; // BOOTMODE btmod; struct mmc_host *mmc = (struct mmc_host*)data; struct msdc_host *host = NULL; int id; unsigned int vcore_uv = 0; //btmod = get_boot_mode(); //printk("btmod = %d\n", btmod); if (1/*(btmod!=META_BOOT) && (btmod!=FACTORY_BOOT) && (btmod!=ATE_FACTORY_BOOT)*/){ sdio_host_debug = 0; //host = mtk_msdc_host[id]; host = mmc_priv(mmc); id = host->id; #ifndef UT_TEST // 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); #endif #ifdef AUTOK_THREAD for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == id && p_autok_thread_data->p_autok_progress[i].done == 1 && p_autok_thread_data->p_autok_progress[i].fail == 0) { vcore_uv = autok_get_current_vcore_offset(); msdc_autok_stg2_cal(host, &p_autok_predata[id], vcore_uv); break; } } if (i != HOST_MAX_NUM) goto EXIT_WAIT_AUTOK_READY; #endif for(i=0; i<HOST_MAX_NUM; i++){ if(p_autok_thread_data->p_autok_progress[i].host_id == -1 || p_autok_thread_data->p_autok_progress[i].host_id == id){ send_autok_uevent("s2_ready", host); init_completion(&p_autok_thread_data->autok_completion[i]); p_autok_thread_data->p_autok_progress[i].done = 0; p_autok_thread_data->p_autok_progress[i].fail = 0; p_autok_thread_data->p_autok_progress[i].host_id = id; wait_for_completion_interruptible(&p_autok_thread_data->autok_completion[i]); for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == id && p_autok_thread_data->p_autok_progress[i].fail == 1) { ret = -1; break; } } send_autok_uevent("s2_done", host); break; } } //reset_autok_cursor(0); EXIT_WAIT_AUTOK_READY: #ifndef UT_TEST // release host autok_release_host(host); #ifdef CONFIG_SDIOAUTOK_SUPPORT //mt_cpufreq_disable(0, false); //FIXME@CCJ mt_vcore_dvfs_disable_by_sdio(0, false); #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 #endif } return ret; }
int wait_sdio_autok_ready(void *data) { int i; int ret = 0; enum boot_mode_t btmod; struct mmc_host *mmc = (struct mmc_host *)data; struct msdc_host *host = NULL; int id; unsigned int vcore_uv = 0; btmod = get_boot_mode(); pr_debug("btmod = %d\n", btmod); if ((btmod != NORMAL_BOOT) && (btmod != META_BOOT)) { pr_debug("Not META or normal boot, return directly\n"); return 0; } if (1 /*(btmod!=META_BOOT) && (btmod!=FACTORY_BOOT) && (btmod!=ATE_FACTORY_BOOT) */) { sdio_host_debug = 0; /* host = mtk_msdc_host[id]; */ host = mmc_priv(mmc); id = host->id; #ifndef UT_TEST /* claim host */ #ifdef CONFIG_SDIOAUTOK_SUPPORT /* ALPS02017456 */ /* true if dwork was pending, false otherwise */ if (cancel_delayed_work_sync(&(host->set_vcore_workq)) == 0) pr_debug("** no pending vcore_workq\n"); else pr_debug("** cancel vcore_workq\n"); /* ALPS02017456 */ pr_debug("wait_sdio_autok_ready(): is_vcorefs_can_work= %d\n", is_vcorefs_can_work()); if (vcorefs_request_dvfs_opp(KIR_SDIO, OPPI_PERF) != 0) { /* performance mode, return 0 pass */ /* BUG_ON("vcorefs_request_dvfs_opp@OPPI_PERF fail!\n"); */ pr_err("vcorefs_request_dvfs_opp@OPPI_PERF fail!\n"); } g_autok_vcore_sel[0] = vcorefs_get_curr_voltage(); pr_debug("wait_sdio_autok_ready(): vcorefs_get_curr_voltage= %d\n", vcorefs_get_curr_voltage()); /* mt_cpufreq_disable(0, true); */ /* FIXME@CCJ mt_vcore_dvfs_disable_by_sdio(0, true); */ /* vcorefs_sdio_lock_dvfs(0); //ccyeh */ #endif #ifdef MTK_SDIO30_ONLINE_TUNING_SUPPORT /* ccyeh atomic_set(&host->ot_work.ot_disable, 1); */ #endif /* MTK_SDIO30_ONLINE_TUNING_SUPPORT */ autok_claim_host(host); #endif #ifdef AUTOK_THREAD for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == id && p_autok_thread_data->p_autok_progress[i].done == 1 && p_autok_thread_data->p_autok_progress[i].fail == 0) { vcore_uv = autok_get_current_vcore_offset(); msdc_autok_stg2_cal(host, &p_autok_predata[id], vcore_uv); break; } } if (i != HOST_MAX_NUM) goto EXIT_WAIT_AUTOK_READY; #endif for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == -1 || p_autok_thread_data->p_autok_progress[i].host_id == id) { send_autok_uevent("s2_ready", host); init_completion(&p_autok_thread_data->autok_completion[i]); p_autok_thread_data->p_autok_progress[i].done = 0; p_autok_thread_data->p_autok_progress[i].fail = 0; p_autok_thread_data->p_autok_progress[i].host_id = id; wait_for_completion_interruptible (&p_autok_thread_data->autok_completion[i]); for (i = 0; i < HOST_MAX_NUM; i++) { if (p_autok_thread_data->p_autok_progress[i].host_id == id && p_autok_thread_data->p_autok_progress[i].fail == 1) { ret = -1; break; } } send_autok_uevent("s2_done", host); break; } } /* reset_autok_cursor(0); */ EXIT_WAIT_AUTOK_READY: #ifndef UT_TEST /* release host */ autok_release_host(host); #ifdef CONFIG_SDIOAUTOK_SUPPORT /* mt_cpufreq_disable(0, false); */ /* FIXME@CCJ mt_vcore_dvfs_disable_by_sdio(0, false); */ /* vcorefs_sdio_unlock_dvfs(0);//ccyeh */ if (vcorefs_request_dvfs_opp(KIR_SDIO, OPPI_UNREQ) != 0) { /* un-request, return 0 pass */ /* BUG_ON("vcorefs_request_dvfs_opp@OPPI_UNREQ fail!\n"); */ pr_err("vcorefs_request_dvfs_opp@OPPI_UNREQ fail!\n"); } #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 */ #endif } return ret; }