Exemplo n.º 1
0
static int smi_release(struct inode *inode, struct file *file)
{

#if 0
    unsigned long u4Index = 0 ;
    unsigned long u4AssignCnt = 0;
    unsigned long * pu4Cnt = (unsigned long *)file->private_data;
    MTK_SMI_BWC_CONFIG config;

    for(; u4Index < SMI_BWC_SCEN_CNT ; u4Index += 1)
    {
        if(pu4Cnt[u4Index])
        {
            SMIMSG("Process:%s does not turn off BWC properly , force turn off %d\n" , current->comm , u4Index);
            u4AssignCnt = pu4Cnt[u4Index];
            config.b_on_off = 0;
            config.scenario = (MTK_SMI_BWC_SCEN)u4Index;
            do
            {
                smi_bwc_config( &config , pu4Cnt);
            }
            while(0 < u4AssignCnt);
        }
    }
#endif

    if(NULL != file->private_data)
    {
        kfree(file->private_data);
        file->private_data = NULL;
    }

    return 0;
}
Exemplo n.º 2
0
/*****************************************************************************
 * FUNCTION
 *    smi_probe
 * DESCRIPTION
 *    1. Call smi_register to register SMI Device Number, allocate and Initial SMI cdev struct, call cdev_add.
 *    2. Call class_create and device_create to add SMI device to kerne.
 *    3. Call smi_common_init.
 *    4. Call mau_init.
 * PARAMETERS
 *	  param1 : [IN] struct platform_device *pdev
 *				  No used in this function. 
 * RETURNS
 *    Type: Integer. 0 mean success and others mean fail.
 ****************************************************************************/
static int smi_probe(struct platform_device *pdev)
{
    struct device* smiDevice = NULL;

    if (NULL == pdev) {
        SMIERR("platform data missed");
        return -ENXIO;
    }

    if (smi_register()) {
        dev_err(&pdev->dev,"register char failed\n");
        return -EAGAIN;
    }

    pSmiClass = class_create(THIS_MODULE, "MTK_SMI");
    if (IS_ERR(pSmiClass)) {
        int ret = PTR_ERR(pSmiClass);
        SMIERR("Unable to create class, err = %d", ret);
        return ret;
    }
    smiDevice = device_create(pSmiClass, NULL, smiDevNo, NULL, "MTK_SMI");

    smi_common_init();

    mau_init();

    {
        MTK_MAU_CONFIG mau_disp;
        mau_disp.entry = 0;
        mau_disp.larb = 0;
        mau_disp.start = 0x20000000;
        mau_disp.end = 0xFFFFFFFF;
        mau_disp.virt = 1;
        mau_disp.port_msk = 0xFFFF;
        mau_disp.monitor_read = 1;
        mau_disp.monitor_write = 1;
        mau_config(&mau_disp);
    }

#ifdef SMI_DEFAULT_VR
    {
        MTK_SMI_BWC_CONFIG p_conf;
        p_conf.b_reduce_command_buffer = 1;
        p_conf.scenario = SMI_BWC_SCEN_VR1066;
        smi_bwc_config(&p_conf);
    }
#endif

    //dump_smi_register();
    
    return 0;
}
Exemplo n.º 3
0
/*****************************************************************************
 * FUNCTION
 *    on_larb_power_on
 * DESCRIPTION
 *    Callback after larb clock is enabled.
 * PARAMETERS
 *	  param1 : [IN] struct larb_monitor *h
 *				  No used in this function. 
 *	  param2 : [IN] int larb_idx
 *				  larb index. 
 * RETURNS
 *    None.
 ****************************************************************************/
static void on_larb_power_on(struct larb_monitor *h, int larb_idx)
{
    SMIMSG("on_larb_power_on(), larb_idx=%d \n", larb_idx);
    larb_reg_restore(larb_idx);    
    // larb_clock_on(0, "SMI");
#ifdef SMI_DEFAULT_VR    
    {
        MTK_SMI_BWC_CONFIG p_conf;
        p_conf.b_reduce_command_buffer = 1;
        p_conf.scenario = SMI_BWC_SCEN_VR1066;
        smi_bwc_config(&p_conf);
    }  
#endif
}
Exemplo n.º 4
0
/*****************************************************************************
 * FUNCTION
 *    smi_ioctl
 * DESCRIPTION
 *	  File operations - unlocked_ioctl
 *		1. call copy_from_user to get user space parameter
 *		2. call internal function by operation.
 * PARAMETERS
 *	  param1 : [IN] struct file * pFile
 *				  file structure*.
 *	  param2 : [IN] unsigned int cmd
 *				  operation command.
 *	  param3 : [IN] unsigned long param
 *				  parameter of ioctl.
 * RETURNS
 *    Type: Integer. zero means success and others mean error.
 ****************************************************************************/
static long smi_ioctl(struct file * pFile,
                       unsigned int cmd,
                       unsigned long param)
{
    int ret = 0;
    
    switch (cmd)
    {
        case MTK_CONFIG_MM_MAU:
        {
        	MTK_MAU_CONFIG b;
       		if(copy_from_user(&b, (void __user *)param, sizeof(b)))
        	{
            	SMIERR("copy_from_user failed!");
            	ret = -EFAULT;
        	} else {
                mau_config(&b);
			}
        	return ret;
    	}
        case MTK_IOC_SMI_BWC_CONFIG:
            {
                MTK_SMI_BWC_CONFIG cfg;
                ret = copy_from_user(&cfg, (void*)param , sizeof(MTK_SMI_BWC_CONFIG));
                if(ret)
                {
                    SMIMSG(" SMI_BWC_CONFIG, copy_from_user failed: %d\n", ret);
                    return -EFAULT;
                }  

                smi_bwc_config( &cfg );
            
            }
            break;

        default:
            return -1;
    }

	return ret;
}
Exemplo n.º 5
0
static long smi_ioctl( struct file * pFile,
						 unsigned int cmd,
						 unsigned long param)
{
    int ret = 0;

//    unsigned long * pu4Cnt = (unsigned long *)pFile->private_data;

    switch (cmd)
    {
#ifdef __MAU_SPC_ENABLE__ 
        case MTK_CONFIG_MM_MAU:
        {
        	MTK_MAU_CONFIG b;
       		if(copy_from_user(&b, (void __user *)param, sizeof(b)))
        	{
            	SMIERR("copy_from_user failed!");
            	ret = -EFAULT;
        	} else {
                mau_config(&b);
			}
        	return ret;
    	}
        case MTK_IOC_SPC_CONFIG :
        {
            MTK_SPC_CONFIG cfg;
            ret = copy_from_user(&cfg, (void*)param , sizeof(MTK_SPC_CONFIG));
            if(ret)
            {
            	SMIMSG(" SPC_CONFIG, copy_from_user failed: %d\n", ret);
            	return -EFAULT;
            }  

            spc_config(&cfg);

        }
            break;

        case MTK_IOC_SPC_DUMP_REG :
            spc_dump_reg();
            break;


        case MTK_IOC_SPC_DUMP_STA :
            spc_status_check();    	
            break;

        case MTK_IOC_SPC_CMD :
            spc_test(param);
            break;
#endif

        case MTK_IOC_SMI_BWC_CONFIG:
            {
                MTK_SMI_BWC_CONFIG cfg;
                ret = copy_from_user(&cfg, (void*)param , sizeof(MTK_SMI_BWC_CONFIG));
                if(ret)
                {
                    SMIMSG(" SMI_BWC_CONFIG, copy_from_user failed: %d\n", ret);
                    return -EFAULT;
                }  

//                ret = smi_bwc_config( &cfg , pu4Cnt);
                ret = smi_bwc_config( &cfg , NULL);
            
            }
            break;
    // GMP start 
    case MTK_IOC_SMI_BWC_INFO_SET:
        {
            MTK_SMI_BWC_INFO_SET cfg;
            SMIMSG("Handle MTK_IOC_SMI_BWC_INFO_SET request... start");
            ret = copy_from_user(&cfg, (void*)param , sizeof(MTK_SMI_BWC_INFO_SET));
            if(ret)
            {
                SMIMSG(" MTK_IOC_SMI_BWC_INFO_SET, copy_to_user failed: %d\n", ret);
                return -EFAULT;
            }  
            // Set the address to the value assigned by user space program
            smi_bwc_mm_info_set(cfg.property, cfg.value1, cfg.value2);
            SMIMSG("Handle MTK_IOC_SMI_BWC_INFO_SET request... finish");
            break;  
        }
    case MTK_IOC_SMI_BWC_INFO_GET:
        {
            MTK_SMI_BWC_INFO_GET cfg;
            MTK_SMI_BWC_MM_INFO * return_address = NULL;
            
            SMIMSG("Handle MTK_IOC_SMI_BWC_INFO_GET request... start");
            ret = copy_from_user(&cfg, (void*)param , sizeof(MTK_SMI_BWC_INFO_GET));

            if(ret)
            {
                SMIMSG(" MTK_IOC_SMI_BWC_INFO_GET, copy_to_user failed: %d\n", ret);
                return -EFAULT;
            }  

            return_address = (MTK_SMI_BWC_MM_INFO *)cfg.return_address;
            if( return_address != NULL){
                ret = copy_to_user((void*) return_address, (void*)&g_smi_bwc_mm_info, sizeof(MTK_SMI_BWC_MM_INFO));

                if(ret)
                {
                    SMIMSG(" MTK_IOC_SMI_BWC_INFO_GET, copy_to_user failed: %d\n", ret);
                    return -EFAULT;
                }
            }
            SMIMSG("Handle MTK_IOC_SMI_BWC_INFO_GET request... finish");
            break;
        }
     // GMP end   
        
        default:
            return -1;
    }

	return ret;
}
Exemplo n.º 6
0
static long smi_ioctl( struct file * pFile,
						 unsigned int cmd,
						 unsigned long param)
{
    int ret = 0;

//    unsigned long * pu4Cnt = (unsigned long *)pFile->private_data;

    switch (cmd)
    {
#ifdef __MAU_SPC_ENABLE__ 
        case MTK_CONFIG_MM_MAU:
        {
        	MTK_MAU_CONFIG b;
       		if(copy_from_user(&b, (void __user *)param, sizeof(b)))
        	{
            	SMIERR("copy_from_user failed!");
            	ret = -EFAULT;
        	} else {
                mau_config(&b);
			}
        	return ret;
    	}
        case MTK_IOC_SPC_CONFIG :
        {
            MTK_SPC_CONFIG cfg;
            ret = copy_from_user(&cfg, (void*)param , sizeof(MTK_SPC_CONFIG));
            if(ret)
            {
            	SMIMSG(" SPC_CONFIG, copy_from_user failed: %d\n", ret);
            	return -EFAULT;
            }  

            spc_config(&cfg);

        }
            break;

        case MTK_IOC_SPC_DUMP_REG :
            spc_dump_reg();
            break;


        case MTK_IOC_SPC_DUMP_STA :
            spc_status_check();    	
            break;

        case MTK_IOC_SPC_CMD :
            spc_test(param);
            break;
#endif

        case MTK_IOC_SMI_BWC_CONFIG:
            {
                MTK_SMI_BWC_CONFIG cfg;
                ret = copy_from_user(&cfg, (void*)param , sizeof(MTK_SMI_BWC_CONFIG));
                if(ret)
                {
                    SMIMSG(" SMI_BWC_CONFIG, copy_from_user failed: %d\n", ret);
                    return -EFAULT;
                }  

//                ret = smi_bwc_config( &cfg , pu4Cnt);
                ret = smi_bwc_config( &cfg , NULL);
            
            }
            break;
        
        default:
            return -1;
    }

	return ret;
}