static int fake_sdio_device(void *data)
{
    //struct msdc_host *host = mtk_msdc_host[3];
    struct msdc_host *host = mtk_msdc_host[2];  //Denali use MSDC2 to connect 6630.
    wait_sdio_autok_ready(host->mmc);
    return 0;
}
예제 #2
0
static int lte_autok_writeproc(struct file *file,const char *buffer,
                           size_t count, loff_t *data)
{
    char bufferContent[PROC_BUF_SIZE];
    
    if(count >= PROC_BUF_SIZE)
    {
        printk(KERN_INFO "[%s] proc input size (%d) is larger than buffer size (%d) \n", __func__, (unsigned int)(count), PROC_BUF_SIZE);
        return -EFAULT;
    }
    
    if (copy_from_user(bufferContent, buffer, count))
        return -EFAULT;
        
    bufferContent[count] = '\0';
    
    //printk(KERN_INFO "[%s] bufferContent = %s \n", __func__, bufferContent);
    //printk(KERN_INFO "[%s] lte_dev.sdio_func = 0x%x\n", __func__, lte_dev.sdio_func);
    
    if(strcmp(bufferContent,"system_server") == 0)
    {
        struct task_struct *task;
        
        // send uevent
        printk(KERN_INFO "[%s] system_server\n", __func__);
		
#ifndef NATIVE_AUTOK		
        task = kthread_run(&mtlte_sys_trigger_auto_calibration,NULL,"trigger_autok");
#else        
        task = kthread_run(&wait_sdio_autok_ready, (void*)lte_dev.sdio_func->card->host, "trigger_autok");
#endif        
    }
    else if(strcmp(bufferContent,"autok_done") == 0)
    {
        // change g_autok_finish
		printk(KERN_INFO "[%s] autok_done\n", __func__);
        //lte_autok_finish = 1;
        lte_autok_finish++;
        lte_autok_running--;
    }
    else
    {
        // send uevent
		printk(KERN_INFO "[%s] %s\n", __func__, bufferContent);
#ifndef NATIVE_AUTOK
        mtlte_sys_trigger_auto_calibration(NULL);
#else        
        //wait_sdio_autok_ready((void*)lte_dev.sdio_func->card->host);
        wait_sdio_autok_ready((void*)lte_dev.sdio_func->card->host, 0);
#endif        
    }

    return count;
}
예제 #3
0
int sdio_detect_do_autok(int chipId)
{
#if MTK_HIF_SDIO_AUTOK_ENABLED
	BOOTMODE boot_mode;
	
	boot_mode = get_boot_mode();
	
	if (boot_mode == META_BOOT)
	{
		WMT_DETECT_INFO_FUNC("omit autok in meta mode\n");
		return 0;
	}
	
	if (0x6630 == chipId)
  {
		#ifdef CONFIG_SDIOAUTOK_SUPPORT
		if (NULL!= g_func)
		{
			WMT_DETECT_INFO_FUNC("wait_sdio_autok_ready++\n");
	    wait_sdio_autok_ready(g_func->card->host);
	    WMT_DETECT_INFO_FUNC("wait_sdio_autok_ready--\n");
	  }
	  else
	  {
	  	WMT_DETECT_INFO_FUNC("g_func NULL, omit autok\n");
	  }
	  #else
	  	WMT_DETECT_INFO_FUNC("MTK_SDIOAUTOK_SUPPORT not defined\n");
		#endif
	}
	else
	{
		WMT_DETECT_INFO_FUNC("MT%x does not support SDIO3.0 autoK is not needed\n", chipId);
	}
#else
	WMT_DETECT_INFO_FUNC("MTK_HIF_SDIO_AUTOK_ENABLED is not defined\n");
#endif
	return 0;
}
예제 #4
0
static int fake_sdio_device(void *data)
{
    struct msdc_host *host = mtk_msdc_host[3];
    wait_sdio_autok_ready(host->mmc);
    return 0;
}
예제 #5
0
static 
int mtlte_sys_sdio_probe( struct sdio_func *func, const struct sdio_device_id *id)
{
	int ret ; 
	//char net_mac[6] ;
#ifdef MT_LTE_AUTO_CALIBRATION	
  #ifndef NATIVE_AUTOK
	int lte_autok_finish_next;
  #endif
	BOOTMODE btmod;
#endif

    unsigned int orig_WHCR = 0;
    unsigned int changed_WHCR = 0;
    unsigned int orig_WPLRCR = 0;
    unsigned int changed_WPLRCR = 0;
    
    KAL_RAWPRINT(("[PROBE] =======> mt_lte_sdio_probe\n")); 

#ifdef MT_LTE_AUTO_CALIBRATION
    mtlte_sdio_probe_done = 0;
#endif

    LTE_WD_timeout_indicator = 0;
    
	lte_dev.card_exist = 1 ;
	lte_dev.sdio_thread_kick = 0 ;   
    lte_dev.sdio_thread_kick_isr = 0 ; 
    lte_dev.sdio_thread_kick_own_timer = 0 ; 
	lte_dev.sdio_thread_state = SDIO_THREAD_IDLE ; 
	lte_dev.sdio_func = func ;

    /*  Because MT7208 SDIO device add the r/w busy function, 
            We only can use block read at Tx/Rx port.  
            This  quirk is force host to use block access if the transfer byte is equal to n*block size  */
//	    func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;

    /*  Because MT7208 SDIO device not support read 512 byte in data block 
            This  quirk is set byte mode size to max 511 byte  */
    func->card->quirks |= MMC_QUIRK_BROKEN_BYTE_MODE_512;

    /* enable the sdio device function */
	if ((ret = sdio_open_device(func)) != KAL_SUCCESS){
		KAL_RAWPRINT(("[PROBE] XXXXXX mt_lte_sdio_probe -sdio_open_device fail \n")); 
		goto OPEN_FAIL ;
	}
	
#ifdef MT_LTE_AUTO_CALIBRATION
    btmod = get_boot_mode();
    printk("btmod = %d\n", btmod);
    if ((btmod!=META_BOOT) && (btmod!=FACTORY_BOOT) && (btmod!=ATE_FACTORY_BOOT))
    {
#ifndef NATIVE_AUTOK 
        lte_autok_finish = 0;
        lte_autok_finish_next = lte_autok_finish + 1;
    //    KAL_RAWPRINT(("[AUTOK] =======> mtlte_sys_trigger_auto_calibration\n"));
        mtlte_sys_trigger_auto_calibration(NULL);
    //	KAL_RAWPRINT(("lte_autok_finish = %d\n", lte_autok_finish));
    
        while (lte_autok_finish_next != lte_autok_finish){
            KAL_SLEEP_MSEC(50);
        }
#else
      //wait_sdio_autok_ready((void*)lte_dev.sdio_func->card->host);
      wait_sdio_autok_ready((void*)lte_dev.sdio_func->card->host, force_autok);
      force_autok = 0;

#endif
      
    //	KAL_RAWPRINT(("lte_autok_finish = %d\n", lte_autok_finish));
    }
#endif

#ifdef MT_LTE_ONLINE_TUNE_SUPPORT
    ot_set_dev_sleep_sts((void*)lte_dev.sdio_func->card->host, 0);
    ot_dev_wakeup( (void*)lte_dev.sdio_func->card->host );
#endif


	mtlte_hif_register_hif_to_sys_wake_callback(mtlte_sys_sdio_kick_thread, 0) ;
    mtlte_hif_register_hif_to_sys_sleep_callback(mtlte_sys_sdio_sleep_thread, 0) ;
	
	if ((ret = mtlte_hif_sdio_probe()) != KAL_SUCCESS){
		KAL_RAWPRINT(("[PROBE] XXXXXX mt_lte_sdio_probe -mtlte_hif_sdio_probe fail \n")); 
		goto HIF_PROBE_FAIL ;
	}
		
	
	/* sync with the Device FW */
#if 1 
	if ((ret = mtlte_hif_sdio_wait_FW_ready()) != KAL_SUCCESS){
		KAL_RAWPRINT(("[PROBE] XXXXXX mt_lte_sdio_probe -mtlte_hif_sdio_wait_FW_ready fail \n")); 
		goto HIF_PROBE_FAIL ;
	}	
#endif

	/* do the data flow layer probing */
	if ((ret = mtlte_df_probe()) != KAL_SUCCESS){
		KAL_RAWPRINT(("[PROBE] XXXXXX mt_lte_sdio_probe -mtlte_df_probe fail \n")); 
		goto DF_PROBE_FAIL ;
	}

    if ((ret = mtlte_expt_probe()) != KAL_SUCCESS){
		KAL_RAWPRINT(("[INIT] XXXXXX lte_sdio_driver_init -sdio_register_driver fail \n")); 
		goto DF_PROBE_FAIL ; 
    }

    KAL_DBGPRINT(KAL, DBG_ERROR,("[%s] set the WPLRCR for NEW FPGA... \n",KAL_FUNC_NAME)) ;
    
    /* Set the Default value of RX MAX Report Num due MT6290 SDIO HW's flexibility */
    sdio_func1_rd(SDIO_IP_WHCR, &orig_WHCR, 4);
    changed_WHCR = orig_WHCR | RPT_OWN_RX_PACKET_LEN;
    sdio_func1_wr(SDIO_IP_WHCR, &changed_WHCR, 4);

    sdio_func1_rd(SDIO_IP_WPLRCR, &orig_WPLRCR, 4);
    changed_WPLRCR = orig_WPLRCR;
    changed_WPLRCR &= (~(RX_RPT_PKT_LEN(0)));
    changed_WPLRCR |= MT_LTE_RXQ0_MAX_PKT_REPORT_NUM<<(8*0);
    changed_WPLRCR &= (~(RX_RPT_PKT_LEN(1)));
    changed_WPLRCR |= MT_LTE_RXQ1_MAX_PKT_REPORT_NUM<<(8*1);
    changed_WPLRCR &= (~(RX_RPT_PKT_LEN(2)));
    changed_WPLRCR |= MT_LTE_RXQ2_MAX_PKT_REPORT_NUM<<(8*2);
    changed_WPLRCR &= (~(RX_RPT_PKT_LEN(3)));
    changed_WPLRCR |= MT_LTE_RXQ3_MAX_PKT_REPORT_NUM<<(8*3);

    sdio_func1_wr(SDIO_IP_WPLRCR, &changed_WPLRCR, 4);	

#if EMCS_SDIO_DRVTST		
	if ((ret = mtlte_dev_test_probe(LTE_TEST_DEVICE_MINOR, &func->dev)) != KAL_SUCCESS){
		KAL_RAWPRINT(("[PROBE] XXXXXX mt_lte_sdio_probe -mtlte_dev_test_probe %d fail \n", LTE_TEST_DEVICE_MINOR)); 
		goto PROBE_TEST_DRV_FAIL ;
	}
#endif	
    
	/* Sync with FW */
	//TODO5:
	
	/* start the kthread */
	lte_dev.sdio_thread = kthread_run(mtlte_sys_sdio_thread, &lte_dev, "mt_sdio_kthread");
    if (IS_ERR(lte_dev.sdio_thread)) {
        ret = -EBUSY ;
        KAL_RAWPRINT(("[PROBE] XXXXXX mt_lte_sdio_probe -kthread_run fail \n")); 
        goto CREATE_THREAD_FAIL;
    }	

	/* Enable the SDIO TXRX handle process */
	mtlte_hif_sdio_txrx_proc_enable(1) ;
	KAL_RAWPRINT(("[PROBE] mtlte_hif_sdio_txrx_proc_enable enalbe it. \n")); 

    // Test the WHISR read before enable interrupt for 6575 debug
    //mtlte_hif_sdio_get_driver_own();
    //sdio_func1_rd(SDIO_IP_WHISR, hif_sdio_handler.enh_whisr_cache,sizeof(sdio_whisr_enhance));

    /* enable the sdio interrupt service */  
    if ((ret = mtlte_sys_sdio_setup_irq(func)) != KAL_SUCCESS){
		KAL_RAWPRINT(("[PROBE] XXXXXX mt_lte_sdio_probe -mtlte_sys_sdio_setup_irq fail \n")); 
        goto SETUP_IRQ_FAIL;
    }

#ifdef MT_LTE_AUTO_CALIBRATION
        mtlte_sdio_probe_done = 1;
#endif
	KAL_RAWPRINT(("[PROBE] <======= mt_lte_sdio_probe\n")); 	
	
	return ret ;

SETUP_IRQ_FAIL:
	kthread_stop(lte_dev.sdio_thread); 	
CREATE_THREAD_FAIL:

#if EMCS_SDIO_DRVTST		
	mtlte_dev_test_detach(LTE_TEST_DEVICE_MINOR) ;
PROBE_TEST_DRV_FAIL:
#endif

	mtlte_df_remove_phase1() ;
	mtlte_df_remove_phase2() ;
DF_PROBE_FAIL:
	mtlte_hif_sdio_remove_phase1() ;
	mtlte_hif_sdio_remove_phase2() ;
HIF_PROBE_FAIL:
	sdio_close_device(func) ;
OPEN_FAIL:

	KAL_RAWPRINT(("[PROBE FAIL] <======= mt_lte_sdio_probe\n")); 	
	
	return -ENODEV ;
}