From patchwork Thu Oct 16 12:58:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 5091711 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9C9A8C11AC for ; Thu, 16 Oct 2014 12:58:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4094201EC for ; Thu, 16 Oct 2014 12:58:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D728201D3 for ; Thu, 16 Oct 2014 12:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbaJPM6f (ORCPT ); Thu, 16 Oct 2014 08:58:35 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:21232 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752445AbaJPM6b (ORCPT ); Thu, 16 Oct 2014 08:58:31 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDJ009KTG658IB0@mailout2.w1.samsung.com>; Thu, 16 Oct 2014 14:01:17 +0100 (BST) X-AuditID: cbfec7f4-b7f156d0000063c7-c5-543fc0f44789 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 5F.65.25543.4F0CF345; Thu, 16 Oct 2014 13:58:28 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NDJ00F34G17BB00@eusync2.samsung.com>; Thu, 16 Oct 2014 13:58:28 +0100 (BST) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Kyungmin Park , Robert Baldyga , Paul Zimmerman , Krzysztof Kozlowski Subject: [PATCH 7/9] usb: dwc2/gadget: use soft disconnect mode for implementing pullup control Date: Thu, 16 Oct 2014 14:58:03 +0200 Message-id: <1413464285-24172-8-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1413464285-24172-1-git-send-email-m.szyprowski@samsung.com> References: <1413464285-24172-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDJMWRmVeSWpSXmKPExsVy+t/xK7pfDtiHGMz7xWrx+oWhxdmmN+wW M87vY7JYtKyV2WLtkbvsFtunTGeyeHB4J7sDu0ffllWMHlv2f2b0+LxJLoA5issmJTUnsyy1 SN8ugSvj8NEWxoIPghV7Ox4xNjD+5uti5OSQEDCR+P1qBhuELSZx4d56IJuLQ0hgKaPE3+2n mSCcPiaJred2soBUsQkYSnS97QLrEBFwkFiy9A5YB7PAHUaJ9fs/MYEkhAUSJVr2nwNrYBFQ ldjxYDtYnFfAQ+LS7EvMEOvkJP6/XAEW5xTwlNi1eSVYXAio5vzV6YwTGHkXMDKsYhRNLU0u KE5KzzXUK07MLS7NS9dLzs/dxAgJoS87GBcfszrEKMDBqMTDqxFsHyLEmlhWXJl7iFGCg1lJ hHfRJKAQb0piZVVqUX58UWlOavEhRiYOTqkGRkdd2eLjkZcjXf88f6GoI5X94cg8rqxsoS3P +Jsv+tcy9G0KfGNhV7rtvaE719r6kItHY/XqKvfdzbeo4a/T2DFduL04xmHnQuuY0xnVCbPM Hmrott9qjzxe6sPLdDrp6cRvhzpvaMziyYxmv2zE2MmyY7tY5d9FRxRZ754+8z9yneSuibsF lViKMxINtZiLihMBmA75oP8BAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch moves PHY enable and disable calls from pullup method to udc_start/stop functions and adds calls to recently introduces soft disconnect mode in pullup method. This improves dwc2 gadget driver compatibility with gadget API requirements (now pullup method really forces soft disconnect mode instead of shutting down the whole hardware) and as a side effect also solves the issue related to limited caller context for PHY related functions (they cannot be called from non-sleeping context). Signed-off-by: Marek Szyprowski --- drivers/usb/dwc2/gadget.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index d039334967d7..cdf417a7ae63 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2883,6 +2883,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget, struct usb_gadget_driver *driver) { struct s3c_hsotg *hsotg = to_hsotg(gadget); + unsigned long flags; int ret; if (!hsotg) { @@ -2919,7 +2920,15 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget, goto err; } + s3c_hsotg_phy_enable(hsotg); + + spin_lock_irqsave(&hsotg->lock, flags); + s3c_hsotg_init(hsotg); + s3c_hsotg_core_init_disconnected(hsotg); + spin_unlock_irqrestore(&hsotg->lock, flags); + dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name); + return 0; err: @@ -2957,6 +2966,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget, spin_unlock_irqrestore(&hsotg->lock, flags); + s3c_hsotg_phy_disable(hsotg); + regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); clk_disable(hsotg->clk); @@ -2990,14 +3001,13 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on) dev_dbg(hsotg->dev, "%s: is_on: %d\n", __func__, is_on); spin_lock_irqsave(&hsotg->lock, flags); + if (is_on) { - s3c_hsotg_phy_enable(hsotg); clk_enable(hsotg->clk); - s3c_hsotg_core_init_disconnected(hsotg); s3c_hsotg_core_connect(hsotg); } else { + s3c_hsotg_core_disconnect(hsotg); clk_disable(hsotg->clk); - s3c_hsotg_phy_disable(hsotg); } hsotg->gadget.speed = USB_SPEED_UNKNOWN;