Exemplo n.º 1
0
static int mipi_r61529_lcd_off(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;

	mfd = platform_get_drvdata(pdev);

	if (!mfd)
		return -ENODEV;
	if (mfd->key != MFD_KEY)
		return -EINVAL;

	mipi_dsi_cmds_tx(mfd, &r61529_tx_buf,
			mipi_r61529_pdata->power_off_set,
			mipi_r61529_pdata->power_off_set_size);

	mipi_ldp_lcd_panel_poweroff();

	return 0;
}
/********************************************************************
Function Name  :-  drive_pwm_pin_to_high
Arguments 	   :-  None
Return Value   :-  int / Always Success.
Functionality  :-  Power off / reset / power on / lcd panel init.
dependencies   :-  Panel Should be already ON.
 Others        :-  By writing 0 to pwm_pin parameter (module/mipi_lg4573/)
 					we can re-initialize panel.
 			For Software ESD simulation Testing.
*********************************************************************/
static int drive_pwm_pin_to_high()
{
	struct msm_fb_data_type *mfd;
	int ret = 0;
	printk("%s Enter \n",__func__);
	mfd = platform_get_drvdata(local_pdev_for_pwm);
	if (!mfd)
		return -ENODEV;
	if (mfd->key != MFD_KEY)
		return -EINVAL;
	
	mipi_dsi_op_mode_config(DSI_CMD_MODE);
	mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_disp_off_cmds,
			ARRAY_SIZE(lg4573b_disp_off_cmds));

	mipi_ldp_lcd_panel_poweroff();//reset pin
	esd_sw_test_lcd_panel_power_off(); //power
	
	mdelay(500);

	esd_sw_test_lcd_panel_power_on(); //panel power on
	
	mipi_set_tx_power_mode(1);
	mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_init_on_cmds,
			ARRAY_SIZE(lg4573b_init_on_cmds));
	mdelay(10);
	mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_sleep_out_cmds,
			ARRAY_SIZE(lg4573b_sleep_out_cmds));
	mdelay(120);
	mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_disp_on_cmds,
			ARRAY_SIZE(lg4573b_disp_on_cmds));
	mipi_set_tx_power_mode(0);
	
	mipi_dsi_op_mode_config(DSI_VIDEO_MODE); //back to video mode.

	printk("%s Exit \n",__func__);

	return ret;
}
static int mipi_lg4573b_lcd_off(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
/* LGE_CHANGE_S : LCD ESD Protection 
 * LCD ESD Protection
 */
#ifdef CONFIG_LGE_LCD_ESD_DETECTION	
	bool int_en_wq_ret;
	bool panel_power_on_wq_ret;

	if ( (!local_pdev_for_pwm) && (pdev) )
	{
		local_pdev_for_pwm = pdev;
	}
#endif
/* LGE_CHANGE_E : LCD ESD Protection*/ 

	mfd = platform_get_drvdata(pdev);

	if (!mfd)
		return -ENODEV;
	if (mfd->key != MFD_KEY)
		return -EINVAL;

	printk(KERN_INFO "mipi_lg4573b_chip_lcd_off START\n");
/* LGE_CHANGE_S : LCD ESD Protection 
 * LCD ESD Protection
 */
#ifdef CONFIG_LGE_LCD_ESD_DETECTION
/*Set panel power off state to TRUE & flush the INTR EN Work queue*/
/*Don't enable esd irq in wq handler as we are powering off panel */	
	if( 0 == atomic_read(&lcd_esd->panel_poweroff) ) 
	{
		atomic_set(&lcd_esd->panel_poweroff,1);
	}
	int_en_wq_ret = flush_delayed_work_sync(&lcd_esd->esd_int_en_work);
	if ( true == int_en_wq_ret )
		printk("Waited for intr work to finish \n");
	panel_power_on_wq_ret = flush_delayed_work_sync(&lcd_esd->esd_dsi_panel_on);
	if( true == panel_power_on_wq_ret )
		printk("Waited for Panel On work to finish \n");
/*Disable ESD interrupt while powering off*/
	if( 1 == atomic_read(&lcd_esd->esd_irq_state))
	{
		disable_irq(lcd_esd->esd_irq);
		printk("ESD irq Disabled \n");
		atomic_set(&lcd_esd->esd_irq_state,0);
	}
#endif
/* LGE_CHANGE_E : LCD ESD Protection*/ 


//LGE_CHANGE_S [Kiran] Change LCD sleep sequence
	//display off
#ifdef CONFIG_LGE_LCD_ESD_DETECTION
	if(false == is_esd_occured)
#endif
	{
		mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_disp_off_cmds,
			ARRAY_SIZE(lg4573b_disp_off_cmds));

		msleep(40);
	}
//LGE_CHANGE_E [Kiran] Change LCD sleep sequence
/*LCD Reset After data pulled Down*/
#if 0
	mipi_ldp_lcd_panel_poweroff();
#endif
/*LGE_CHANGE_E LCD Reset After Data Pulled Down*/
#ifdef CONFIG_FB_MSM_MIPI_DSI_LG4573B_BOOT_LOGO
	lglogo_firstboot = FALSE;
#endif
/*LCD off end Log added 27-01-2012*/	
	printk("End %s \n",__func__);
	return 0;
}
/*LGE_CHANGE_E LCD Reset After Data Pulled Down*/
static int mipi_dsi_off(struct platform_device *pdev)
{
	int ret = 0;
	struct msm_fb_data_type *mfd;
	struct msm_panel_info *pinfo;

	mfd = platform_get_drvdata(pdev);
	pinfo = &mfd->panel_info;

	if (mdp_rev >= MDP_REV_41)
		mutex_lock(&mfd->dma->ov_mutex);
	else
		down(&mfd->dma->mutex);

	mdp4_overlay_dsi_state_set(ST_DSI_SUSPEND);

	/*
	 * Description: dsi clock is need to perform shutdown.
	 * mdp4_dsi_cmd_dma_busy_wait() will enable dsi clock if disabled.
	 * also, wait until dma (overlay and dmap) finish.
	 */
	if (mfd->panel_info.type == MIPI_CMD_PANEL) {
		if (mdp_rev >= MDP_REV_41) {
			mdp4_dsi_cmd_dma_busy_wait(mfd);
			mdp4_dsi_blt_dmap_busy_wait(mfd);
			mipi_dsi_mdp_busy_wait(mfd);
		} else {
			mdp3_dsi_cmd_dma_busy_wait(mfd);
		}
	}

	/*
	 * Desctiption: change to DSI_CMD_MODE since it needed to
	 * tx DCS dsiplay off comamnd to panel
	 */
//LGE_CHANGE_S [Kiran] Change LCD sleep sequence
/*LCD Reset After data pulled Down*/
#if 0
	if(lglogo_firstboot)
	{
		mipi_dsi_op_mode_config(DSI_CMD_MODE);
	}
#endif
/*LGE_CHANGE_E LCD Reset After Data Pulled Down*/
//LGE_CHANGE_E [Kiran] Change LCD sleep sequence

	if (mfd->panel_info.type == MIPI_CMD_PANEL) {
		if (pinfo->lcd.vsync_enable) {
			if (pinfo->lcd.hw_vsync_mode && vsync_gpio >= 0) {
				if (MDP_REV_303 != mdp_rev)
					gpio_free(vsync_gpio);
			}
			mipi_dsi_set_tear_off(mfd);
		}
	}

	ret = panel_next_off(pdev);

#ifdef CONFIG_MSM_BUS_SCALING
	mdp_bus_scale_update_request(0);
#endif
/*In case of ESD no delays required in power off*/
//LGE_CHANGE_S [Kiran] Change LCD sleep sequence
#ifdef CONFIG_LGE_LCD_ESD_DETECTION
	if (true == is_esd_occured)
	{
		printk("ESD.Paneloff ASAP\n");
	}
	else
#endif
		msleep(300);
//LGE_CHANGE_E [Kiran] Change LCD sleep sequence

#ifdef CONFIG_FB_MSM_MIPI_DSI_LG4573B_BOOT_LOGO
	if(lglogo_firstboot)
	{
		printk(KERN_INFO "[DISPLAY]::%s\n",__func__);
		local_bh_disable();
		lglogo_mipi_dsi_clk_disable();
		local_bh_enable();
	}
	else
#endif
	{
		local_bh_disable();
		mipi_dsi_clk_disable();
		local_bh_enable();
	}

	/* disbale dsi engine */
	MIPI_OUTP(MIPI_DSI_BASE + 0x0000, 0);

	mipi_dsi_phy_ctrl(0);

#ifdef CONFIG_FB_MSM_MIPI_DSI_LG4573B_BOOT_LOGO       
	if(!lglogo_firstboot)
#endif
    {
		local_bh_disable();
		mipi_dsi_ahb_ctrl(0);
		local_bh_enable();
    }
//LGE_CHANGE_S [Kiran] Change LCD sleep sequence
#if 1
		/* MDP cmd block enable */
		mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE);
		MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 0);
		/* MDP cmd block disable */
		mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE);
		/*Turning off DMA_P block*/
		mdp_pipe_ctrl(MDP_DMA2_BLOCK, MDP_BLOCK_POWER_OFF, FALSE);
#endif
//LGE_CHANGE_E [Kiran] Change LCD sleep sequence
/*LCD Reset After data pulled Down*/
	mipi_ldp_lcd_panel_poweroff();
/*LGE_CHANGE_E LCD Reset After Data Pulled Down*/

	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save)
		mipi_dsi_pdata->dsi_power_save(0);

	if (mdp_rev >= MDP_REV_41)
		mutex_unlock(&mfd->dma->ov_mutex);
	else
		up(&mfd->dma->mutex);

	pr_debug("%s-:\n", __func__);

#ifdef CONFIG_FB_MSM_MIPI_DSI_LG4573B_BOOT_LOGO
	lglogo_firstboot = FALSE;
#endif
	return ret;
}