usb: gadget: s3c-hsotg: add proper suspend/resume support
This patch adds suspend/resume support to s3c-hsotg driver. It makes UDC driver more power efficient. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
		
					parent
					
						
							
								aecbc31d76
							
						
					
				
			
			
				commit
				
					
						b83e333a4d
					
				
			
		
					 1 changed files with 49 additions and 4 deletions
				
			
		| 
						 | 
					@ -3774,10 +3774,55 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 1
 | 
					static int s3c_hsotg_suspend(struct platform_device *pdev, pm_message_t state)
 | 
				
			||||||
#define s3c_hsotg_suspend NULL
 | 
					{
 | 
				
			||||||
#define s3c_hsotg_resume NULL
 | 
						struct s3c_hsotg *hsotg = platform_get_drvdata(pdev);
 | 
				
			||||||
#endif
 | 
						unsigned long flags;
 | 
				
			||||||
 | 
						int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (hsotg->driver)
 | 
				
			||||||
 | 
							dev_info(hsotg->dev, "suspending usb gadget %s\n",
 | 
				
			||||||
 | 
								 hsotg->driver->driver.name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spin_lock_irqsave(&hsotg->lock, flags);
 | 
				
			||||||
 | 
						s3c_hsotg_disconnect(hsotg);
 | 
				
			||||||
 | 
						s3c_hsotg_phy_disable(hsotg);
 | 
				
			||||||
 | 
						hsotg->gadget.speed = USB_SPEED_UNKNOWN;
 | 
				
			||||||
 | 
						spin_unlock_irqrestore(&hsotg->lock, flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (hsotg->driver) {
 | 
				
			||||||
 | 
							int ep;
 | 
				
			||||||
 | 
							for (ep = 0; ep < hsotg->num_of_eps; ep++)
 | 
				
			||||||
 | 
								s3c_hsotg_ep_disable(&hsotg->eps[ep].ep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
 | 
				
			||||||
 | 
										     hsotg->supplies);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int s3c_hsotg_resume(struct platform_device *pdev)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct s3c_hsotg *hsotg = platform_get_drvdata(pdev);
 | 
				
			||||||
 | 
						unsigned long flags;
 | 
				
			||||||
 | 
						int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (hsotg->driver) {
 | 
				
			||||||
 | 
							dev_info(hsotg->dev, "resuming usb gadget %s\n",
 | 
				
			||||||
 | 
								 hsotg->driver->driver.name);
 | 
				
			||||||
 | 
							ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
 | 
				
			||||||
 | 
									      hsotg->supplies);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spin_lock_irqsave(&hsotg->lock, flags);
 | 
				
			||||||
 | 
						hsotg->last_rst = jiffies;
 | 
				
			||||||
 | 
						s3c_hsotg_phy_enable(hsotg);
 | 
				
			||||||
 | 
						s3c_hsotg_core_init(hsotg);
 | 
				
			||||||
 | 
						spin_unlock_irqrestore(&hsotg->lock, flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_OF
 | 
					#ifdef CONFIG_OF
 | 
				
			||||||
static const struct of_device_id s3c_hsotg_of_ids[] = {
 | 
					static const struct of_device_id s3c_hsotg_of_ids[] = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue