From patchwork Mon Oct 20 10:45:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 5104191 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E2A629F374 for ; Mon, 20 Oct 2014 10:46:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CB31201D3 for ; Mon, 20 Oct 2014 10:46:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D0CF20176 for ; Mon, 20 Oct 2014 10:46:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753598AbaJTKqB (ORCPT ); Mon, 20 Oct 2014 06:46:01 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:33978 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529AbaJTKp4 (ORCPT ); Mon, 20 Oct 2014 06:45:56 -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 <0NDQ000WQOP20M10@mailout4.w1.samsung.com>; Mon, 20 Oct 2014 11:48:38 +0100 (BST) X-AuditID: cbfec7f5-b7f956d000005ed7-4f-5444e7dfb1a2 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 33.92.24279.FD7E4445; Mon, 20 Oct 2014 11:45:51 +0100 (BST) 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 <0NDQ009U7OK7MS20@eusync4.samsung.com>; Mon, 20 Oct 2014 11:45:51 +0100 (BST) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Felipe Balbi , Kyungmin Park , Robert Baldyga , Paul Zimmerman , Krzysztof Kozlowski Subject: [PATCH v2 08/10] usb: dwc2/gadget: use soft-disconnect udc feature in pullup() method Date: Mon, 20 Oct 2014 12:45:38 +0200 Message-id: <1413801940-31086-9-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1413801940-31086-1-git-send-email-m.szyprowski@samsung.com> References: <1413801940-31086-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMJMWRmVeSWpSXmKPExsVy+t/xa7r3n7uEGBx5YGhx8H69xesXhhZn m96wW8w4v4/JYtGyVmaLtUfusltsnzKdyeLB4Z3sDhwefVtWMXps2f+Z0eP4je1MHp83yQWw RHHZpKTmZJalFunbJXBlfD87ib3gLm/FiV2PWBoYD3J3MXJySAiYSKw4/5cFwhaTuHBvPVsX IxeHkMBSRokfJy4xQjh9TBLX529mBqliEzCU6HrbxQZiiwg4SCxZegfMZhb4ySgxeapNFyMH h7BAgsSpXk6QMIuAqsT3nfMZQWxeAQ+Ja4v6mSCWyUn8f7kCzOYU8JR482IaWI0QUM2m5S9Z JjDyLmBkWMUomlqaXFCclJ5rpFecmFtcmpeul5yfu4kRElBfdzAuPWZ1iFGAg1GJh3eHmUuI EGtiWXFl7iFGCQ5mJRHe7ttAId6UxMqq1KL8+KLSnNTiQ4xMHJxSDYxKJ6ynMQscfdzoUBps YPDWYZPhkv1u08S4t/7mUju2a8HU+pMVFxtVPlZ5y36pTWP6vffignbrtw/ZeG0ci+0T2L7M 5JZi+MhZ5rD9irJEtL/u+bSKs0VzuucaszNI6zsefdHBvDK24KOR+7HyWTr1FhE+yoEuC9Ot ffruFRnra3+81PK0SImlOCPRUIu5qDgRAJ5HDGAGAgAA 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=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 udc initialization from pullup() method to s3c_hsotg_udc_start(), so that method ends with hardware fully initialized and left in soft-disconnected state. After this change, the pullup() method simply clears soft-disconnect start() when called with is_on=1. For completeness, a call to s3c_hsotg_core_disconnect() has been added when pullup() method is called with is_on=0, what puts the udc hardware back to soft-disconnected state. Signed-off-by: Marek Szyprowski Acked-by: Paul Zimmerman --- drivers/usb/dwc2/gadget.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 98adf8d17493..e8ffc080e6c7 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) { @@ -2921,7 +2922,13 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget, 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: @@ -2994,9 +3001,9 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on) spin_lock_irqsave(&hsotg->lock, flags); if (is_on) { 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); }