Esempio n. 1
0
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;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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);
#ifndef _DVFS_ENABLE_              
                mt_vcore_dvfs_disable_by_sdio(0, true);
#else                
                vcorefs_sdio_lock_dvfs(0);
#endif                
                #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;
              }
          }
          break;
        default:
            break;        
    }
    return count;
}
Esempio n. 4
0
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();
	/*pr_debug("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);
        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);
    	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;
}