Esempio n. 1
0
int autok_hook_redo(struct msdc_host *host)
{    
#ifdef USER_BUILD_KERNEL
    int i;
    for(i=0; i<HOST_MAX_NUM; i++){
        if(p_autok_thread_data->p_autok_progress[i].host_id == host->id){
            p_autok_thread_data->p_autok_progress[i].done = 0;            
        }
    }    
    p_autok_predata[host->id].vol_count = 0;
    sdio_autok_processed = 0;
    if(!vcorefs_is_95m_segment()){
        kfree(suggest_vol);
        suggest_vol_count = 1;
        suggest_vol = kzalloc(sizeof(unsigned int)*suggest_vol_count, GFP_KERNEL);
        suggest_vol[0] = 1125000;
    }
    send_autok_uevent("bus_error", host);
#endif    
    return 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();
    //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;
}
Esempio n. 3
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;
}
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;
}