From patchwork Fri Oct 31 08:04:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 39859 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 AAE8E2405B for ; Fri, 31 Oct 2014 08:04:59 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf284038wiw.3 for ; Fri, 31 Oct 2014 01:04:58 -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=Vf3ePM2rq2qJteL1ZMSWec6haJ/TuafU4S7JoQi2du8=; b=Em8k5crA+h8OPUubOgSJckToIbKqVhE3sl0TWihDxN21p1DxXFTX47aZ3JUbEdA+lm AablZ9Sq6bnO1dduobHz0POq8Po4OEhPYpL2McVsOmXKOmVwrb8pfouBag62RxDFCnCT PGB4Vus73lvrIzrRjgiM3HAX6GSDofVO99ihfBoDQeh0/oQmeNCWRV0UT2jznFj4Ygv5 H7kMUmxHlZC7j/zGf8SKCdiTaKR38t66GO/m/WkT4rGjB3QTiO6ZEmk2Qb5HRhnrMAtE MZvafTjvCzbY+vDGy7TP8e4p2Rpso9DhHERwUc+f2DWIagBzTsDzHd/ASX4Dlp6gC9oE KG7w== X-Gm-Message-State: ALoCoQn9xi0O7m3xLxliPEzns17UP50hzH2/z30KN+3dTRaG1LSc0uZlpUv/ZxTPAoq7vKbSYnxA X-Received: by 10.152.4.38 with SMTP id h6mr149732lah.9.1414742698835; Fri, 31 Oct 2014 01:04:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.34 with SMTP id t2ls459966lal.2.gmail; Fri, 31 Oct 2014 01:04:58 -0700 (PDT) X-Received: by 10.152.88.105 with SMTP id bf9mr24545768lab.30.1414742698699; Fri, 31 Oct 2014 01:04:58 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id jo7si15490467lbc.39.2014.10.31.01.04.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 01:04:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id pv20so3872484lab.25 for ; Fri, 31 Oct 2014 01:04:58 -0700 (PDT) X-Received: by 10.153.8.164 with SMTP id dl4mr24368719lad.29.1414742698532; Fri, 31 Oct 2014 01:04:58 -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 c5csp164413lbz; Fri, 31 Oct 2014 01:04:57 -0700 (PDT) X-Received: by 10.70.40.134 with SMTP id x6mr22683589pdk.99.1414742696654; Fri, 31 Oct 2014 01:04:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wj9si8528732pbc.252.2014.10.31.01.04.56 for ; Fri, 31 Oct 2014 01:04:56 -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 S1751917AbaJaIEy (ORCPT + 3 others); Fri, 31 Oct 2014 04:04:54 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:18759 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751409AbaJaIEw (ORCPT ); Fri, 31 Oct 2014 04:04:52 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEA0082QUKNDIA0@mailout4.w1.samsung.com>; Fri, 31 Oct 2014 08:07:35 +0000 (GMT) X-AuditID: cbfec7f5-b7f956d000005ed7-dd-545342a132f6 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id AF.DC.24279.1A243545; Fri, 31 Oct 2014 08:04:49 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NEA003C8UFXAD20@eusync4.samsung.com>; Fri, 31 Oct 2014 08:04:49 +0000 (GMT) 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 , Felipe Balbi Subject: [PATCH v3] usb: dwc2/gadget: report disconnect event from 'end session' irq Date: Fri, 31 Oct 2014 09:04:28 +0100 Message-id: <1414742668-4107-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1413801940-31086-2-git-send-email-m.szyprowski@samsung.com> References: <1413801940-31086-2-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEJMWRmVeSWpSXmKPExsVy+t/xa7oLnYJDDKatlbU4eL/e4vULQ4uz TW/YLWac38dksWhZK7PF2iN32S22T5nOZPHg8E52Bw6Pvi2rGD227P/M6HH8xnYmj8+b5AJY orhsUlJzMstSi/TtErgyWlamFvwSqPg7YS1jA+Md3i5GTg4JAROJfUdOs0HYYhIX7q0Hsrk4 hASWMkq8nr2RCcLpY5LYfu8fWBWbgKFE19suMFtEwEFiydI7YDazwE9GiUs/+LoYOTiEBcIk bt1SBwmzCKhKPPzfyQxi8wq4S+w918ECsUxO4v/LFUwgNqeAp8SxH3vBxggJeEisWPaMcQIj 7wJGhlWMoqmlyQXFSem5RnrFibnFpXnpesn5uZsYIeH0dQfj0mNWhxgFOBiVeHg1vgSFCLEm lhVX5h5ilOBgVhLhnfQWKMSbklhZlVqUH19UmpNafIiRiYNTqoFR6+TDWEsvu1vCYnvCWy9u niN3vIkp6PXE5ydXf98d/5En9svW5Z++/b1+0pw578Ari3+PLNZVG4QvVovUiPWcarxv10vO GTcjJvzL9BDW//aEa0vRbCM+/idTjsx60izdefPXrdmH1qVMX/uj+Od0iedv1zvt6pRa8jnB 8dUWF8ZQE7UlnqYxG5VYijMSDbWYi4oTAdL+ZsQFAgAA 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.52 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 adds a call to s3c_hsotg_disconnect() from 'end session' interrupt (GOTGINT_SES_END_DET) to correctly notify gadget subsystem about unplugged usb cable. 'disconnected' interrupt (DISCONNINT) might look a bit more suitable for this event, but it is asserted only in host mode, so in device mode we need to use something else. Additional check has been added in s3c_hsotg_disconnect() function to ensure that the event is reported only once after successful device enumeration. Signed-off-by: Marek Szyprowski --- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 55c90c53f2d6..b42df32e7737 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -212,6 +212,7 @@ struct s3c_hsotg { struct usb_gadget gadget; unsigned int setup; unsigned long last_rst; + unsigned int address; struct s3c_hsotg_ep *eps; }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index fcd2bb55ccca..6304efba11aa 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1114,6 +1114,7 @@ static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg, DCFG_DEVADDR_SHIFT) & DCFG_DEVADDR_MASK; writel(dcfg, hsotg->regs + DCFG); + hsotg->address = ctrl->wValue; dev_info(hsotg->dev, "new address %d\n", ctrl->wValue); ret = s3c_hsotg_send_reply(hsotg, ep0, NULL, 0); @@ -2031,6 +2032,10 @@ static void s3c_hsotg_disconnect(struct s3c_hsotg *hsotg) { unsigned ep; + if (!hsotg->address) + return; + + hsotg->address = 0; for (ep = 0; ep < hsotg->num_of_eps; ep++) kill_all_requests(hsotg, &hsotg->eps[ep], -ESHUTDOWN, true); @@ -2290,6 +2295,11 @@ irq_retry: dev_info(hsotg->dev, "OTGInt: %08x\n", otgint); writel(otgint, hsotg->regs + GOTGINT); + + if (otgint & GOTGINT_SES_END_DET) { + s3c_hsotg_disconnect(hsotg); + hsotg->gadget.speed = USB_SPEED_UNKNOWN; + } } if (gintsts & GINTSTS_SESSREQINT) {