From patchwork Thu Oct 16 12:58:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 38809 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 92A0F20973 for ; Thu, 16 Oct 2014 12:58:53 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf2030782wiw.3 for ; Thu, 16 Oct 2014 05:58:52 -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=Pvsks+eZ+UfGI7LteMH12B45QRbReCjZmX+NWxMkVOw=; b=aqrLFnvY72V1Pe/KytIv7GAVYyxZOt029njq6mvRgWJZQya3JizL+GhOA3MUCOkeIS 4w8SZJzs/Ru3Jfkq2iAz+7kRaF89y8NvHDYtqqt1Zn0E86qz5vkxe/H0oX28EXed6gEt EZNXaTnGfqVSsRyMvutm6a3hVuzCY/9evoDKYGWye35J9lffH3dMpqWwz7uAo/wy00Wz OS1dwsCc2LhuRLvHEecWMbvyFpbrexyYMh+WbesCKdFLz7o1tbMDyNXHlMVj5LBWzE/+ j0lzxW00e1ql9BHCT/biEi0KG6jvddmR1BUaM3kA7vds7GNn3jM3WIIoRaALGv9n4/Li 1u8g== X-Gm-Message-State: ALoCoQkRYiLTLUkVN1nTOceZ40wQwDM5zj8OhQZXbaYrxIOMhCTF3fXFNM9KMjBb/sajXb+fAPCs X-Received: by 10.112.224.1 with SMTP id qy1mr255004lbc.8.1413464332678; Thu, 16 Oct 2014 05:58:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.200 with SMTP id le8ls163033lab.101.gmail; Thu, 16 Oct 2014 05:58:52 -0700 (PDT) X-Received: by 10.112.135.229 with SMTP id pv5mr1521864lbb.52.1413464332515; Thu, 16 Oct 2014 05:58:52 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx.google.com with ESMTPS id uf2si34608153lbb.103.2014.10.16.05.58.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Oct 2014 05:58:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id z11so2776768lbi.13 for ; Thu, 16 Oct 2014 05:58:52 -0700 (PDT) X-Received: by 10.152.36.103 with SMTP id p7mr1514864laj.44.1413464332400; Thu, 16 Oct 2014 05:58:52 -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 c5csp33528lbz; Thu, 16 Oct 2014 05:58:51 -0700 (PDT) X-Received: by 10.70.53.38 with SMTP id y6mr1207184pdo.168.1413464329407; Thu, 16 Oct 2014 05:58:49 -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.48 for ; Thu, 16 Oct 2014 05:58:49 -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 S1752494AbaJPM6r (ORCPT + 6 others); Thu, 16 Oct 2014 08:58:47 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:57455 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751608AbaJPM6a (ORCPT ); Thu, 16 Oct 2014 08:58:30 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDJ00HMXG6APB80@mailout1.w1.samsung.com>; Thu, 16 Oct 2014 14:01:22 +0100 (BST) X-AuditID: cbfec7f5-b7f776d000003e54-f5-543fc0f304f7 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 21.FC.15956.3F0CF345; Thu, 16 Oct 2014 13:58:27 +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:27 +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 6/9] usb: dwc2/gadget: decouple setting soft disconnect from s3c_hsotg_core_init Date: Thu, 16 Oct 2014 14:58:02 +0200 Message-id: <1413464285-24172-7-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/xK7qfD9iHGDTuV7d4/cLQ4mzTG3aL Gef3MVksWtbKbLH2yF12i+1TpjNZPDi8k92B3aNvyypGjy37PzN6fN4kF8AcxWWTkpqTWZZa pG+XwJXx68Id1oLvIhWT381kbmBcLNjFyMkhIWAi8frfY1YIW0ziwr31bF2MXBxCAksZJdrX bmCFcPqYJC4cecgCUsUmYCjR9baLDcQWEXCQWLL0DlgHs8AdRon1+z8xgSSEBZIkHs1+CtbA IqAq8WLFPkYQm1fAQ+LTl2fMEOvkJP6/XAFWzyngKbFr80qwuBBQzfmr0xknMPIuYGRYxSia WppcUJyUnmukV5yYW1yal66XnJ+7iRESQl93MC49ZnWIUYCDUYmHVyPYPkSINbGsuDL3EKME B7OSCO+iSUAh3pTEyqrUovz4otKc1OJDjEwcnFINjLNn7+jduILjXI7BLaMrXisiP3VyBB06 GTvrrPdqOV1lQwWfwPp3z+zncvy20Z4Qtkx0976V9+NVvu6/POtZzU31nRXHg7SEitmnGudf kxBdq/DgC9+1S69ie1r8Hu1un+Jwq+VK7rJWA2aJVO8cQYFVKjzHU5+XX7FKsrZpUW6t7HLe 27BzoxJLcUaioRZzUXEiAN+iIXL/AQAA 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.217.182 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 changes s3c_hsotg_core_init function to leave hardware in soft disconnect mode, so the actual moment of coupling the hardware to the usb bus can be later controlled by the driver in the more accurate way. For this purpose, separate functions for enabling and disabling soft disconnect mode have been added. Signed-off-by: Marek Szyprowski --- drivers/usb/dwc2/gadget.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 1ba0682fb252..d039334967d7 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2124,7 +2124,7 @@ static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg) * * Issue a soft reset to the core, and await the core finishing it. */ -static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg) +static void s3c_hsotg_core_init_disconnected(struct s3c_hsotg *hsotg) { s3c_hsotg_corereset(hsotg); @@ -2241,14 +2241,23 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg) readl(hsotg->regs + DOEPCTL0)); /* clear global NAKs */ - writel(DCTL_CGOUTNAK | DCTL_CGNPINNAK, + writel(DCTL_CGOUTNAK | DCTL_CGNPINNAK | DCTL_SFTDISCON, hsotg->regs + DCTL); /* must be at-least 3ms to allow bus to see disconnect */ mdelay(3); hsotg->last_rst = jiffies; +} + +static void s3c_hsotg_core_disconnect(struct s3c_hsotg *hsotg) +{ + /* set the soft-disconnect bit */ + __orr32(hsotg->regs + DCTL, DCTL_SFTDISCON); +} +static void s3c_hsotg_core_connect(struct s3c_hsotg *hsotg) +{ /* remove the soft-disconnect and let's go */ __bic32(hsotg->regs + DCTL, DCTL_SFTDISCON); } @@ -2348,7 +2357,8 @@ irq_retry: kill_all_requests(hsotg, &hsotg->eps[0], -ECONNRESET, true); - s3c_hsotg_core_init(hsotg); + s3c_hsotg_core_init_disconnected(hsotg); + s3c_hsotg_core_connect(hsotg); } } } @@ -2983,7 +2993,8 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on) if (is_on) { s3c_hsotg_phy_enable(hsotg); clk_enable(hsotg->clk); - s3c_hsotg_core_init(hsotg); + s3c_hsotg_core_init_disconnected(hsotg); + s3c_hsotg_core_connect(hsotg); } else { clk_disable(hsotg->clk); s3c_hsotg_phy_disable(hsotg); @@ -3670,7 +3681,8 @@ static int s3c_hsotg_resume(struct platform_device *pdev) spin_lock_irqsave(&hsotg->lock, flags); s3c_hsotg_phy_enable(hsotg); - s3c_hsotg_core_init(hsotg); + s3c_hsotg_core_init_disconnect(hsotg); + s3c_hsotg_core_connect(hsotg); spin_unlock_irqrestore(&hsotg->lock, flags); return ret;