Exemplo n.º 1
0
static int s3c_udc_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct s3c_udc *dev = platform_get_drvdata(pdev);
	unsigned long flags;


	DEBUG_PM("[%s]: System Suspend \n", __func__);
#if NO_USING_USB_SWITCH 
	DEBUG_PM("[%s]: NO_USING_USB_SWITCH just return\n", __func__);
	return 0;
#endif
	spin_lock_irqsave(&dev->lock, flags);


	//save the state of connection to udc_resume_state
	dev->udc_resume_state = dev->udc_state;
	dev->udc_resume_speed = dev->gadget.speed;

	if (dev->gadget.speed != USB_SPEED_UNKNOWN) {
		DEBUG_PM("[%s]: USB enumerated at suspend\n", __func__);
		//s3c_udc_soft_disconnect();		
		s3c_udc_stop_activity(dev, dev->driver);
	}
	else {
		DEBUG_PM("[%s] USB not enumerated at suspend\n", __func__);
		DEBUG_PM("[%s] dev->powered [%d] at suspend\n", __func__, dev->powered);
		if (dev->powered == 0) {
			DEBUG_PM("[%s] skip~~ s3c_udc_power_down() at suspend\n", __func__);
			spin_unlock_irqrestore(&dev->lock, flags);
		return 0;
		}
	}

	switch(pm_policy)
	{
		case ALL_POWER_DOWN:			
//			s3c_udc_stop_activity(dev, dev->driver);
			//confirm clk disable
			s3c_udc_power_down();
			break;
		case CLOCK_GATING: 		
			s3c_udc_suspend_clock_gating();
			break;
		case OPHYPWR_FORCE_SUSPEND:			
			writel((readl(S3C_USBOTG_PHYPWR)|(1<<FORCE_SUSPEND)), S3C_USBOTG_PHYPWR);
			break;
		default:
			DEBUG_ERROR("[%s]: not proper pm_policy\n", __func__);
	}
	spin_unlock_irqrestore(&dev->lock, flags);
	return 0;
}
static int s3c_udc_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct s3c_udc *dev = platform_get_drvdata(pdev);

	DEBUG_PM("[%s]: System Suspend \n", __FUNCTION__);

	//save the state of connection to udc_resume_state
	if (dev->gadget.speed != USB_SPEED_UNKNOWN)
	{
		dev->udc_resume_state = dev->udc_state;
		DEBUG_PM("[%s]: USB connected at suspend\n", __FUNCTION__);
	}
	else
	{
		dev->udc_resume_state = dev->udc_state;
		DEBUG_PM("[%s]: USB not connected at suspend\n", __FUNCTION__);
	}

	switch(pm_policy)
	{
		case ALL_POWER_DOWN:			
			s3c_udc_soft_disconnect();
			stop_activity(dev, dev->driver);
			//confirm clk disable
			s3c_udc_power_down();
			break;
		case CLOCK_GATING: 		
			s3c_udc_suspend_clock_gating();
			break;
		case OPHYPWR_FORCE_SUSPEND:			
			writel((readl(S3C_USBOTG_PHYPWR)|1), S3C_USBOTG_PHYPWR);
			break;
		default:
			printk("[%s]: not proper pm_policy\n", __FUNCTION__);
	}
	return 0;
}