From patchwork Fri Feb 28 12:06:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 25532 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DE57120543 for ; Fri, 28 Feb 2014 12:06:42 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id c41sf1378520yho.5 for ; Fri, 28 Feb 2014 04:06:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ar2K6LJpPaddoYTqCOVdwpLedMIGk78A3RwlNkG17tg=; b=GWfzo9UvF5KI/Y74n6a0v19Ga28MPL1fze4xjrH9iRc6N6QIklTm1UaUQ7Wz+/rW1G YPXHlPemS0Eaf2q1VUBLrbjN7e+H0007UYo3fwmrmfilvmWcQxm07FldZy1saxe4rmcc eTuDai5ZXdv6ShWUAw/Tbem5FtL41uDzegJvbbE3nMWLqf3/0WmNEtI9Ii2uYHnR+bQO pUbWZYnbzBKZ6cfbX1mywk1Yk+sfgbmsfLQ/ObhynaLEATbnph993WMLXTc7viQXvucT qpBIzw6In9pX62rxZ8TWYE5HiaIB7EBKarfCt7iLfpw5/DUL8F13gPzVsGA5Wsu9MMNY KOnQ== X-Gm-Message-State: ALoCoQmtKFvsEU+w/U22rEgWgNntaCw2AGo9p+9SCxzl1pW2Yl89PKUjy8NWUlutjrORCj342yfK X-Received: by 10.58.37.72 with SMTP id w8mr1027056vej.29.1393589202489; Fri, 28 Feb 2014 04:06:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.201 with SMTP id d67ls1084156qgd.62.gmail; Fri, 28 Feb 2014 04:06:42 -0800 (PST) X-Received: by 10.52.89.230 with SMTP id br6mr13288055vdb.20.1393589202401; Fri, 28 Feb 2014 04:06:42 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id t20si196532vek.3.2014.02.28.04.06.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Feb 2014 04:06:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so637592veb.28 for ; Fri, 28 Feb 2014 04:06:42 -0800 (PST) X-Received: by 10.58.188.78 with SMTP id fy14mr2231631vec.23.1393589202326; Fri, 28 Feb 2014 04:06:42 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp48853vcs; Fri, 28 Feb 2014 04:06:41 -0800 (PST) X-Received: by 10.66.12.67 with SMTP id w3mr3110543pab.29.1393589200710; Fri, 28 Feb 2014 04:06:40 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si1826026pab.145.2014.02.28.04.06.32; Fri, 28 Feb 2014 04:06:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752095AbaB1MGb (ORCPT + 3 others); Fri, 28 Feb 2014 07:06:31 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:31336 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbaB1MGa (ORCPT ); Fri, 28 Feb 2014 07:06:30 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N1P007LQGATK680@mailout4.samsung.com> for linux-usb@vger.kernel.org; Fri, 28 Feb 2014 21:06:29 +0900 (KST) X-AuditID: cbfee61a-b7fb26d00000724f-5f-53107bc54d12 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BF.F0.29263.5CB70135; Fri, 28 Feb 2014 21:06:29 +0900 (KST) Received: from AMDC2122.DIGITAL.local ([106.120.53.17]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N1P00KWFGADET00@mmp1.samsung.com>; Fri, 28 Feb 2014 21:06:29 +0900 (KST) From: Robert Baldyga To: balbi@ti.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, m.szyprowski@samsung.com, andrzej.p@samsung.com Subject: [PATCH] drivers: s3c-hsotg: add proper suspend/resume support Date: Fri, 28 Feb 2014 13:06:11 +0100 Message-id: <1393589171-14987-1-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBJMWRmVeSWpSXmKPExsVy+t9jAd2j1QLBBluvCFvMetnOYnHwfr1F 8+L1bBaLlrUyW6w9cpfdgdVj/9w17B59W1Yxehy/sZ3J4/MmuQCWKC6blNSczLLUIn27BK6M va3lBcsEK/bfXc7cwHiIr4uRk0NCwESi89lPNghbTOLCvfVANheHkMAiRom/b1cxQzjtTBLr nlxnAaliE9CR2PJ9AiOILSIgILH+xSV2EJtZIEeiacEDoG4ODmEBN4mzmwRBTBYBVYm5C8F2 8Qq4SjR/3ccKEpYQUJCYM8lmAiP3AkaGVYyiqQXJBcVJ6bmGesWJucWleel6yfm5mxjB/n8m tYNxZYPFIUYBDkYlHt4JnvzBQqyJZcWVuYcYJTiYlUR4RQoEgoV4UxIrq1KL8uOLSnNSiw8x SnOwKInzHmi1DhQSSE8sSc1OTS1ILYLJMnFwSjUwTgnl6guKb1Bsj7F//eH3Gs2Ow6+ZDxUa 7VuyM8pkd2XykaA3D0zKq5eJln9Iaty02CA+t2mCuG/P+UaHG7Vf1kxYPEfPMjlUfOZ9s45W o+BH24NN+pgCW5ddL96e+NU490VB/i3FKUbqMUyxPvtd96vUdz+/oPpkXuTSFds2vNPYk3vY yGG3EktxRqKhFnNRcSIAHWAHRfsBAAA= Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Marek Szyprowski This patch adds suspend/resume support to s3c-hsotg driver. It makes UDC driver more power efficient. Signed-off-by: Marek Szyprowski Tested-by: Robert Baldyga --- drivers/usb/gadget/s3c-hsotg.c | 53 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 1172eae..3eaf63e 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -3760,10 +3760,55 @@ static int s3c_hsotg_remove(struct platform_device *pdev) return 0; } -#if 1 -#define s3c_hsotg_suspend NULL -#define s3c_hsotg_resume NULL -#endif +static int s3c_hsotg_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct s3c_hsotg *hsotg = platform_get_drvdata(pdev); + 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 static const struct of_device_id s3c_hsotg_of_ids[] = {