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: 38805 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C94820973 for ; Thu, 16 Oct 2014 12:58:41 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id p9sf1877682lbv.4 for ; Thu, 16 Oct 2014 05:58:40 -0700 (PDT) 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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=vx/zGIAzo7WNo3BLi/jmw0/sXswcmHXzPDTliQ3il6Y=; b=jEx08/xMdRshUH8PorMy9HVS20UXai/sCKPiMsai34QGz06wqWRj9uq1rzOLQVqw2M TFFjDAAu6/kubUZk8q2CcUJpx+pFNBiUfOe7JEEUDbHuvBr1uGtCqxzRuPfwGHJ0nuiD 72E26gkL2oLNrVDAACTGixiZEyWI88BI/crhpbKW7wU6vIvgq9nIFRk+j/NIjxEqPMg1 h+EvljTW1LOxzQlgtU2aefXAe5esXOxDNX4dvlPU0+plbyZY4C2sIKytDjBbhzJh2y/3 hdfSjQkQZidoKq1AZ+6CQBxY1uwDsl3ILXqPiNjrGru1z2kKPdw53iXSfNHvW2wDGHQZ KbMQ== X-Gm-Message-State: ALoCoQlYRd/lxWZxeGbvMkEDvjTGJ6n8I7f0o0MT+nSyCkdCz5/WNfA1kUk4bW77nO59Hzc3cmP+ X-Received: by 10.180.74.130 with SMTP id t2mr911656wiv.4.1413464320948; Thu, 16 Oct 2014 05:58:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.224.161 with SMTP id rd1ls150522lac.95.gmail; Thu, 16 Oct 2014 05:58:40 -0700 (PDT) X-Received: by 10.112.142.200 with SMTP id ry8mr1575257lbb.26.1413464320757; Thu, 16 Oct 2014 05:58:40 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by mx.google.com with ESMTPS id kh7si2522225lbc.17.2014.10.16.05.58.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Oct 2014 05:58:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gi9so2776343lab.21 for ; Thu, 16 Oct 2014 05:58:40 -0700 (PDT) X-Received: by 10.152.120.200 with SMTP id le8mr1364469lab.67.1413464320674; Thu, 16 Oct 2014 05:58:40 -0700 (PDT) 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.112.84.229 with SMTP id c5csp33477lbz; Thu, 16 Oct 2014 05:58:39 -0700 (PDT) X-Received: by 10.70.128.40 with SMTP id nl8mr1059950pdb.131.1413464318779; Thu, 16 Oct 2014 05:58:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yk7si11920691pab.135.2014.10.16.05.58.38 for ; Thu, 16 Oct 2014 05:58:38 -0700 (PDT) Received-SPF: none (google.com: linux-samsung-soc-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbaJPM6f (ORCPT + 6 others); 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: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) 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: , 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;