int hdmi_drv_power_on(void)
{
    int ret = 0;
	HDMI_FUNC();
	mt65xx_eint_mask(CUST_EINT_MHL_NUM);

#if 1
	SiiMhlTxHwGpioResume();
	//pmic_config_interface(0x87,0x1,0x01,0x0);
/* Vanzo:lubaoquan on: Tue, 21 May 2013 22:35:29 +0800
 * TODO: replace this line with your comment
 */
	hwPowerOn(MT65XX_POWER_LDO_VGP5, VOL_1200, "HDMI");
// End of Vanzo: lubaoquan
#endif

	//msleep(100);
    SiiMhlTxHwReset(5,5);

	//xuecheng
	HalInstallCheckDeviceCB(SiiCheckDevice);
    HalAcquireIsrLock();
    siHdmiTx_VideoSel(HDMI_720P60);
    siHdmiTx_AudioSel(I2S_44);
    ret = SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS);
    HalReleaseIsrLock();
	mt65xx_eint_unmask(CUST_EINT_MHL_NUM);
    return ret;
}
Exemple #2
0
static void ResumeWorkFunc(struct work_struct *work)
{
    printk(KERN_INFO "%s Resume MHL start.\n", __func__);

	Sii8334_plat_data->reset();

	msleep(1000);
    //deleted by zhangyue on 2011-12-15 for solving the hpd problems start
    //enable_irq(sii8334_PAGE_TPI->irq);
    //deleted by zhangyue on 2011-12-15 for solving the hpd problems end
    SiiMhlTxInitialize();
    //added by zhangyue on 2011-12-19 for debugging the mhl irq problem start
    printk(KERN_INFO "%s Init Register End.\n", __func__);
    HalTimerWait(30);//wait 30ms before enable registers
    mhl_set_irq_locked(true, false);
    //added by zhangyue on 2011-12-19 for debugging the mhl irq problem end
}
void hdmi_drv_power_on(void)
{
	HDMI_FUNC();
	mt65xx_eint_mask(CUST_EINT_HDMI_HPD_NUM);
	SiiMhlTxHwGpioResume();
	pmic_config_interface(0x87,0x1,0x01,0x0);
	//msleep(100);
    SiiMhlTxHwReset(50,200);

	//xuecheng
	HalInstallCheckDeviceCB(SiiCheckDevice);
    HalAcquireIsrLock();
    siHdmiTx_VideoSel(HDMI_720P60);
    siHdmiTx_AudioSel(I2S_44);
    SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS);
    HalReleaseIsrLock();
	mt65xx_eint_unmask(CUST_EINT_HDMI_HPD_NUM);
}
int32_t ResumeMhlTxDevice(void)
{
	//halReturn_t		halStatus;
	//SiiOsStatus_t	osalStatus;
    printk("Starting %s\n", MHL_PART_NAME);

	SiiMhlTxHwReset(10,200);  
    if(!SiiCraInitialize())
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of CRA layer failed!\n");
    	return -EIO;
    }
   
	//msleep(200);

    HalInstallCheckDeviceCB(SiiCheckDevice);
	HalAcquireIsrLock();
	siHdmiTx_VideoSel(HDMI_720P60);
	siHdmiTx_AudioSel(I2S_44);
    SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS);
    HalReleaseIsrLock();
    return 0;
}
int32_t StartMhlTxDevice(void)
{
	halReturn_t		halStatus;
	SiiOsStatus_t	osalStatus;
    printk("Starting %s\n", MHL_PART_NAME);

	SiiMhlTxHwReset(10,200);  
    if(!SiiCraInitialize())
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of CRA layer failed!\n");
    	return -EIO;
    }
    osalStatus = SiiOsInit(0);
    if (osalStatus != SII_OS_STATUS_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of OSAL failed, error code: %d\n",osalStatus);
    	return -EIO;
    }
    halStatus = HalInit();
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of HAL failed, error code: %d\n",halStatus);
    	SiiOsTerm();
    	return -EIO;
    }

//#if MTK_project
    //xuecheng
    //I2c_Init();
//#endif
  
    halStatus = HalOpenI2cDevice(MHL_PART_NAME, MHL_DRIVER_NAME);
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Opening of I2c device %s failed, error code: %d\n",
    			MHL_PART_NAME, halStatus);
    	HalTerm();
    	SiiOsTerm();
    	return -EIO;
    }
		

	msleep(200);
	
#ifdef SiI8338DRIVER_INTERRUPT_MODE
    halStatus = HalInstallIrqHandler(SiiMhlTxDeviceIsr);
    if (halStatus != HAL_RET_SUCCESS)
    {
    	SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"Initialization of HAL interrupt support failed, error code: %d\n",
    			halStatus);
    	HalCloseI2cDevice();
    	HalTerm();
    	SiiOsTerm();
    	return -EIO;
    }

#else
		StartEventThread();		/* begin monitoring for events if using polling mode*/
#endif
    //xuecheng

    HalInstallCheckDeviceCB(SiiCheckDevice);
	HalAcquireIsrLock();
	siHdmiTx_VideoSel(HDMI_720P60);
	siHdmiTx_AudioSel(I2S_44);
    SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS);
    HalReleaseIsrLock();
    return 0;
}
static int sii9244_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
	int ret = 0;
	struct rkdisplay_platform_data *mhl_data = client->dev.platform_data;
	
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        printk("%s i2c check function err!\n",__func__); 
		return -ENODEV;
	}
	
	if(strcmp(client->name, mhl_sii_id[0].name) == 0) {
		sii9244 = kzalloc(sizeof(struct sii9244), GFP_KERNEL);
		if(!sii9244) {
	        dev_err(&client->dev, "no memory for state\n");
	        goto err_kzalloc_sii9244;
	    }
	    
	    memset(sii9244, 0 ,sizeof(struct sii9244));
		sii9244->client = client;
		
		// Register HDMI device
		if(mhl_data) {
			sii9244->io_pwr_pin = mhl_data->io_pwr_pin;
			sii9244->io_rst_pin = mhl_data->io_reset_pin;
		}
		else {
			sii9244->io_pwr_pin = INVALID_GPIO;
			sii9244->io_rst_pin = INVALID_GPIO;	
		}
		
		//Power on sii902x
		if(sii9244->io_pwr_pin != INVALID_GPIO) {
			ret = gpio_request(sii9244->io_pwr_pin, NULL);
			if(ret) {
				gpio_free(sii9244->io_pwr_pin);
				sii9244->io_pwr_pin = INVALID_GPIO;
	        	printk(KERN_ERR "request sii9244 power control gpio error\n ");
	        	goto err_request_gpio; 
			}
			else
				gpio_direction_output(sii9244->io_pwr_pin, GPIO_HIGH);
		}
		
		if(sii9244->io_rst_pin != INVALID_GPIO) {
			ret = gpio_request(sii9244->io_rst_pin, NULL);
			if(ret) {
				gpio_free(sii9244->io_rst_pin);
				sii9244->io_rst_pin = INVALID_GPIO;
	        	printk(KERN_ERR "request sii9244 reset control gpio error\n ");
	        	goto err_request_gpio; 
			}
			else
				gpio_direction_output(sii9244->io_rst_pin, GPIO_HIGH);
		}
		sii9244->io_irq_pin = client->irq;
		sii9244->workqueue = create_singlethread_workqueue("mhl");
		INIT_DELAYED_WORK(&(sii9244->delay_work), mhl_work);
		
		//
		// Initialize the registers as required. Setup firmware vars.
		//
		SiiMhlTxInitialize( MONITORING_PERIOD );
		
		queue_delayed_work(sii9244->workqueue, &sii9244->delay_work, 0);
			
		dev_info(&client->dev, "sii9244 probe ok\n");
	}
	
	return 0;
	
err_request_gpio:
	if(sii9244->io_rst_pin != INVALID_GPIO)
		gpio_free(sii9244->io_rst_pin);
	if(sii9244->io_pwr_pin != INVALID_GPIO)
		gpio_free(sii9244->io_pwr_pin);
	kfree(sii9244);
	sii9244 = NULL;
err_kzalloc_sii9244:
	dev_err(&client->dev, "sii9244 probe error\n");
	return ret;
}
Exemple #7
0
/*
 * i2c client ftn.
 */
static int __devinit mhl_Sii8334_probe(struct i2c_client *client,
			const struct i2c_device_id *dev_id)
{
    int ret = 0;
    if(match_id(&mhl_Sii8334_idtable[0], client)){
        sii8334_PAGE_TPI = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully\n", dev_id->name);
    }
    /*
    else if(match_id(&mhl_Sii8334_idtable[1], client)){
        sii8334_PAGE_TX_L0 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully \n", dev_id->name);
    }
    */
    else if(match_id(&mhl_Sii8334_idtable[2], client)){
        sii8334_PAGE_TX_L1 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully \n", dev_id->name);
    }else if(match_id(&mhl_Sii8334_idtable[3], client)){
        sii8334_PAGE_TX_2 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully\n", dev_id->name);
    }else if(match_id(&mhl_Sii8334_idtable[4], client)){
        sii8334_PAGE_TX_3 = client;
        dev_info(&client->adapter->dev, "attached %s "
                "into i2c adapter successfully\n", dev_id->name);
    }else if(match_id(&mhl_Sii8334_idtable[5], client))    {
        sii8334_PAGE_CBUS = client;
        dev_info(&client->adapter->dev, "attached %s "
            "into i2c adapter successfully\n", dev_id->name);
    }else{
        dev_info(&client->adapter->dev, "invalid i2c adapter: can not found dev_id matched\n");
        return -EIO;
    }
    
    
    if(sii8334_PAGE_TPI != NULL 
      //&&sii8334_PAGE_TX_L0 != NULL 
      &&sii8334_PAGE_TX_L1 != NULL 
      && sii8334_PAGE_TX_2 != NULL
      && sii8334_PAGE_TX_3 != NULL
      && sii8334_PAGE_CBUS != NULL){
        
        Sii8334_plat_data = sii8334_PAGE_TPI->dev.platform_data;
        #ifdef mhl_power_dbg
        ret = Sii8334_plat_data->mhl_power_on();
        if(ret){
            printk("%s:call mhl_power_on failed.\n", __func__);	
        }
	  //added by zhangyue on 2011-11-21 for config irq	
	  Sii8334_plat_data->mhl_irq_config();
	  //added by zhangyue on 2011-11-21 end
        #endif
        if(false == Sii8334_mhl_reset()){
            printk("/nCan't find the reset function in your platform file============================================\n");
            return -EIO;
        }
        
        // Announce on RS232c port.
        //
        printk("\n============================================\n");
        printk("SiI-8334 Driver Version based on 8051 driver Version 1.14 \n");
        printk("============================================\n");
        
        //
        // Initialize the registers as required. Setup firmware vars.
        //
        
	  SiiMhlTxInitialize();
        
        #ifdef SiI8334DRIVER_INTERRUPT_MODE
        #ifdef zy_dbg_err_handle
        sii8334work = kmalloc(sizeof(*sii8334work), GFP_KERNEL);
         if(NULL == sii8334work){
            printk(KERN_ERR "NO memory for allocating sii8334work.\n");
            ret = -ENOMEM;
            goto ERR_ALLOC_INT_WORK;
        }
        #else
        sii8334work = kmalloc(sizeof(*sii8334work), GFP_ATOMIC);
        #endif
        INIT_WORK(sii8334work, work_queue); 
        #ifdef mhl_power_dbg
        #ifdef zy_dbg_err_handle
        ResumeWork = kmalloc(sizeof(*ResumeWork ),  GFP_ATOMIC);
        if(NULL == ResumeWork){
            printk(KERN_ERR "NO memory for allocating ResumeWork.\n");
	      ret = -ENOMEM;
            goto ERR_ALLOC_RESUM_WORK;
        }
        #else
        ResumeWork = kmalloc(sizeof(*ResumeWork ),  GFP_ATOMIC);
        #endif
        INIT_DELAYED_WORK(ResumeWork, ResumeWorkFunc);
        #endif
        #ifdef ZY_IMPLEMENT_RCP
        mhl_state.rmt_input = input_allocate_device();
        if(NULL == mhl_state.rmt_input){
            printk(KERN_INFO "Bad input_allocate_device()\n");
	      ret = -ENOMEM;
	      goto ERR_ALLOC_INPUT;
        }
	
        mhl_init_rmt_input_dev();
        //Register with the Input subsystem	
        ret = input_register_device(mhl_state.rmt_input);
        if(ret){
            printk(KERN_INFO "Register input device failed.\n ");
            goto ERR_REG_INPUT;
        }
        #endif
        #ifdef zy_dbg_irq
	  //modified by zhangyue on 2011-12-07 
	  //for debugging, because some time, the irq handler not run when the irq came.
	  ret = request_threaded_irq(sii8334_PAGE_TPI->irq, NULL, Sii8334_mhl_interrupt, IRQ_TYPE_LEVEL_LOW |IRQF_ONESHOT, 
        	sii8334_PAGE_TPI->name, sii8334_PAGE_TPI); 
	 #else
        ret = request_irq(sii8334_PAGE_TPI->irq, Sii8334_mhl_interrupt, IRQ_TYPE_LEVEL_LOW,
        sii8334_PAGE_TPI->name, sii8334_PAGE_TPI); 
	  #endif
	  
        if (ret){
            printk(KERN_INFO "%s:%d:Sii8334 interrupt failed\n", __func__,__LINE__);	
            #ifdef zy_dbg_err_handle
            goto ERR_REQ_IRQ;
            #endif
            //free_irq(irq, iface);
        }else{
            #ifdef zy_usrspace_enalbe_mhl_irq
		//modified by zhangyue on 2011-12-26 for debugging the mhl charging	start
		disable_irq(sii8334_PAGE_TPI->irq);
		HalTimerWait(40);//sleep 40ms
		enable_irq(sii8334_PAGE_TPI->irq);
            //disable_irq(sii8334_PAGE_TPI->irq);
		//modified by zhangyue on 2011-12-26 for debugging the mhl charging	end
	      #else
            enable_irq_wake(sii8334_PAGE_TPI->irq);
	      #endif  
            //printk(KERN_INFO "%s:%d:Sii8334 interrupt successed\n", __func__,__LINE__);	
        }
        #ifdef zy_usrspace_enalbe_mhl_irq
        mhl_state.irq_Inited = false;
	 #endif
        #ifdef mhl_power_dbg
        mhl_state.state = true;
        #endif
        #else
        StartEventThread();		/* begin monitoring for events if using polling mode*/
        #endif
        #ifdef zy_dbg_err_handle
        goto ERR_ALLOC_INT_WORK;
        #endif
    ERR_REQ_IRQ:
        input_unregister_device(mhl_state.rmt_input);
    ERR_REG_INPUT:
        input_free_device(mhl_state.rmt_input);
    ERR_ALLOC_INPUT:
        kfree(ResumeWork);
    ERR_ALLOC_RESUM_WORK:
        kfree(sii8334work);
    }
ERR_ALLOC_INT_WORK:
    return ret;
}
/*
 * i2c client ftn.
 */
static int __devinit mhl_Sii8334_probe(struct i2c_client *client,
			const struct i2c_device_id *dev_id)
{
	int ret = 0;

	if(match_id(&mhl_Sii8334_idtable[0], client))
	{
		sii8334_PAGE_TPI = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	/*
	else if(match_id(&mhl_Sii8334_idtable[1], client))
	{
		sii8334_PAGE_TX_L0 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully \n", dev_id->name);
	}
	*/
	else if(match_id(&mhl_Sii8334_idtable[2], client))
	{
		sii8334_PAGE_TX_L1 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully \n", dev_id->name);
	}
	else if(match_id(&mhl_Sii8334_idtable[3], client))
	{
		sii8334_PAGE_TX_2 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	else if(match_id(&mhl_Sii8334_idtable[4], client))
	{
		sii8334_PAGE_TX_3 = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	else if(match_id(&mhl_Sii8334_idtable[5], client))
	{
		sii8334_PAGE_CBUS = client;
		dev_info(&client->adapter->dev, "attached %s "
			"into i2c adapter successfully\n", dev_id->name);
	}
	else
	{
		dev_info(&client->adapter->dev, "invalid i2c adapter: can not found dev_id matched\n");
		return -EIO;
	}


	if(sii8334_PAGE_TPI != NULL 
		//&&sii8334_PAGE_TX_L0 != NULL 
		&&sii8334_PAGE_TX_L1 != NULL 
		&& sii8334_PAGE_TX_2 != NULL
		&& sii8334_PAGE_TX_3 != NULL
		&& sii8334_PAGE_CBUS != NULL)
	{
		// Announce on RS232c port.
		//
		printk("\n============================================\n");
		printk("SiI-8334 Driver Version based on 8051 driver Version 1.0066 \n");
		printk("============================================\n");
		
		if(false == Sii8334_mhl_reset()){
			printk("/nCan't find the reset function in your platform file============================================\n");
			return -EIO;
			}

		//
		// Initialize the registers as required. Setup firmware vars.
		//
	
		SiiMhlTxInitialize();
		
		#ifdef SiI8334DRIVER_INTERRUPT_MODE
		sii8334work = kmalloc(sizeof(*sii8334work), GFP_ATOMIC);
		INIT_WORK(sii8334work, work_queue); 
		
		ret = request_irq(sii8334_PAGE_TPI->irq, Sii8334_mhl_interrupt, IRQ_TYPE_LEVEL_LOW,
					  sii8334_PAGE_TPI->name, sii8334_PAGE_TPI);
		if (ret)
			printk(KERN_INFO "%s:%d:Sii8334 interrupt failed\n", __func__,__LINE__);	
			//free_irq(irq, iface);
		else{
			enable_irq_wake(sii8334_PAGE_TPI->irq);	
			//printk(KERN_INFO "%s:%d:Sii8334 interrupt successed\n", __func__,__LINE__);	
			}
		#else
		StartEventThread();		/* begin monitoring for events if using polling mode*/
		#endif
	}
	return ret;
}
long SiiMhlIoctl(struct file *pFile, unsigned int ioctlCode, unsigned long ioctlParam)
{
	long retStatus = 0;
	Register_t RegisterInfo;
	uint8_t reg;
	UserControl_t user_control;
	if (HalAcquireIsrLock() != HAL_RET_SUCCESS) {
		return -ERESTARTSYS;
	}
	switch (ioctlCode) {
	case SII_IOCTRL_REGISTER_READ:
		retStatus = copy_from_user(&RegisterInfo, (Register_t *) ioctlParam,
					   sizeof(Register_t));
		if (!retStatus) {
			RegisterInfo.value =
			    I2C_ReadByte(RegisterInfo.dev_address, RegisterInfo.subaddr);
			retStatus =
			    copy_to_user((Register_t *) ioctlParam, &RegisterInfo,
					 sizeof(Register_t));
		} else {
			pr_info("register read error!\n");
		}
		break;
	case SII_IOCTRL_REGISTER_WRITE:
		retStatus = copy_from_user(&RegisterInfo, (Register_t *) ioctlParam,
					   sizeof(Register_t));
		reg = I2C_ReadByte(RegisterInfo.dev_address, RegisterInfo.subaddr);
		reg = (reg & (~RegisterInfo.mask)) | (RegisterInfo.mask & RegisterInfo.value);
		I2C_WriteByte(RegisterInfo.dev_address, RegisterInfo.subaddr, reg);
		break;
	case SII_IOCTRL_USER:
		retStatus = copy_from_user(&user_control, (UserControl_t *) ioctlParam,
					   sizeof(UserControl_t));
		switch (user_control.ControlID) {
		case USER_GPIO_GET:
			/* HalGpioGetPin(user_control.SubCommand.GpioCtrl.GpioIndex, &user_control.SubCommand.GpioCtrl.Value); */
			break;
		case USER_GPIO_SET:
			/* HalGpioSetPin(user_control.SubCommand.GpioCtrl.GpioIndex, user_control.SubCommand.GpioCtrl.Value); */
			break;
		case USER_TRIGGER_EXT_INT:
			/* SiiTriggerExtInt(); */
			break;
		case USER_TRIGGER_MHL_INT:
			{
				if (TestDelay != NULL) {
					SiiOsTimerDelete(TestDelay);
					TestDelay = NULL;
				}
				SiiOsTimerCreate("Abort Time Out", SiiMhlTimerTestCB, NULL, true,
						 2000, false, &TestDelay);
			}
			break;
		case USER_ON_OFF_MHL_INT:
			HalEnableIrq(user_control.SubCommand.iSubCommand ? 1 : 0);
			break;
		case USER_RESET_MHL_CHIP:
			SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS);
			break;
		case USER_READ_SINK_EDID:
			{
#define _MASK_(aByte, bitMask, setBits) ((setBits) ? (aByte | bitMask) : (aByte & ~bitMask))
				int RepeatNums = 5, i;
				int iRepeatCnt = 0;
				uint8_t reg;
				uint8_t reg_save;
				reg_save = reg = I2C_ReadByte(0x72, 0xC7);
				reg = _MASK_(reg, BIT0, 1);
				I2C_WriteByte(0x72, 0xc7, reg);
				do {
					if (++iRepeatCnt > RepeatNums)
						break;
					reg = I2C_ReadByte(0x72, 0xC7);
					HalTimerWait(10);
				} while (!(reg & BIT1));
				if (iRepeatCnt > RepeatNums) {
					printk("try time out\n");
				} else {
					reg = I2C_ReadByte(0x72, 0xC7);
					reg = _MASK_(reg, BIT2, 1);
					I2C_WriteByte(0x72, 0xc7, reg);
					for (i = 0; i < 256; i++) {
					}
					I2C_ReadBlock(0xa0, 0, user_control.SubCommand.EDID, 128);
					I2C_ReadBlock(0xa0, 128, &user_control.SubCommand.EDID[128],
						      128);
					I2C_WriteByte(0x72, 0xc7, reg_save);
				}
			}
			break;
		}
		retStatus = copy_to_user((UserControl_t *) ioctlParam,
					 &user_control, sizeof(UserControl_t));
		break;
	default:
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
				"SiiMhlIoctl, unrecognized ioctlCode 0x%0x received!\n", ioctlCode);
		retStatus = -EINVAL;
		break;
	}
	HalReleaseIsrLock();
	return retStatus;
}