/********************************************************************
Function Name  :-  pwm_pin_high_or_low
Arguments 	   :-  None
Return Value   :-  None/Always Success.
Functionality  :-  to Simulate ESD using Module Parameter.  
dependencies   :-  Should be called when lcd panel is on.
Others		   :- pwm_pin --> 1 ( PWM_PIN low & esd isr active )
			      pwm_pin --> 2 ( Dsi reset )
*********************************************************************/
int pwm_pin_high_or_low(const char *val, struct kernel_param *kp)
{
	unsigned long pwm_pin;
	int rc = 0;
	
	if (val == NULL)
	{
		printk("%s Null Buf \n",__func__);
		return -1;
	}
	printk("%s enter \n",__func__);
	pwm_pin = simple_strtoul(val,NULL,10);
	if ( 1 == pwm_pin)
	{
		rc = drive_pwm_pin_to_low();	//ESD Occur	
		if ( rc )
		{
			printk("Error while making pwm pin Low \n");
		}
	}
	else if ( 2 == pwm_pin )
	{
		esd_dsi_reset();
		printk("Dsi Reset Done \n");
	}
	else
	{
		rc = drive_pwm_pin_to_high(); //Normal
		if ( rc )
		{
			printk("Error while making pwm pin High \n");
		}
	}
        return 0;
}
/********************************************************************
Function Name  :-  esd_detect_wq_handler
Arguments 	   :-  Work queue
Return Value   :-  None
Functionality  :-  to disable ESD Irq & issue a dma reset.  
dependencies   :-  Panel should be already intialized.
Others 		   :-  This will be called after 200ms of interrupt occurrence.
*********************************************************************/
static void  esd_detect_wq_handler(struct work_struct *w)
{
	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);
	}
	printk("%s Enter \n",__func__);
	esd_dsi_reset();	
}
/********************************************************************
Function Name  :-  esd_detect_wq_handler
Arguments 	   :-  Work queue
Return Value   :-  None
Functionality  :-  to disable ESD Irq & issue a dma reset.  
dependencies   :-  Panel should be already intialized.
Others 		   :-  This will be called after 200ms of interrupt occurrence.
*********************************************************************/
static void  esd_detect_wq_handler(struct work_struct *w)
{
	if(gpio_get_value_cansleep(lcd_esd->esd_detect_gpio) == GPIO_U0_LCD_ESD_DETECT_PIN_IS_LOW)
	{
		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);
		}
		printk("%s Enter \n",__func__);
		esd_dsi_reset();	
	}
	else /*GPIO_U0_LCD_ESD_DETECT_PIN_IS_HIGH ??*/
	{
		printk("%s LCD_PWM pin is high - do nothing \n",__func__);
	}		
}