From patchwork Wed Dec 28 22:57:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9490701 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 43F0462AB0 for ; Wed, 28 Dec 2016 22:59:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3060B2623D for ; Wed, 28 Dec 2016 22:59:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2546E26490; Wed, 28 Dec 2016 22:59:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD6392623D for ; Wed, 28 Dec 2016 22:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752571AbcL1W7X (ORCPT ); Wed, 28 Dec 2016 17:59:23 -0500 Received: from mail-pg0-f46.google.com ([74.125.83.46]:36106 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752341AbcL1W5k (ORCPT ); Wed, 28 Dec 2016 17:57:40 -0500 Received: by mail-pg0-f46.google.com with SMTP id f188so159841111pgc.3 for ; Wed, 28 Dec 2016 14:57:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mYTMjkxQAIcQAHkHVOczbaXgnAaS+k4HcwrihiqCEJY=; b=cE/F5be+wblmXbUmMaB+K0QaI452KPlQ9YVVg2tnNvkM+DLo68hfNTgSRfL+HV7A0d rlr71uDB5avMesWthuokNr6gcRhk9pLAHgwD+RWChoHlhG8ppiXTaPWiNIsS6OkGY18o HFBqCjdyg2UJ4lxnjKyoyuV18y8GjnqIZX7fE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mYTMjkxQAIcQAHkHVOczbaXgnAaS+k4HcwrihiqCEJY=; b=kVOq0ukK3CE4bhr4owm9pRff8LCn+BVkZCBI14kpla5K9Qzql46yCQsU8gjHl+ezNp duXsghyD+/f4D9QeoLyK96FspUSq0OLMaSyPMFWJG6bxsZcHkc8K/jDZ/hjuiktmvVQI Lm+ft/C6VmHzXDQ7PAFklW5VZX9xm0uGy7Q8LTNqm8VAMVhkA6fq5sq1oNvc9vCrDOCM yznlhU4Jlxofbi7lxpQoU9oFfPCEky6Ql1x83YNmTofaeFMMoyoLGYC35shYFOkeYnq1 ARUcP1oAaIZPvKvuCkxqCKCfqpAlpK3b1gAdmOvEd6mqaRCtBocGNIo5YL6j8JTECybg tniQ== X-Gm-Message-State: AIkVDXJjtMbc4Ba16/5zIcyMxFw4SxcSXUyA0MB36mITCLeU/SQZ3pmkMr58FLH0KICqu/li X-Received: by 10.84.218.204 with SMTP id g12mr80792740plm.78.1482965859740; Wed, 28 Dec 2016 14:57:39 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id x4sm100355741pgc.14.2016.12.28.14.57.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Dec 2016 14:57:39 -0800 (PST) From: Stephen Boyd To: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Peter Chen , Greg Kroah-Hartman Subject: [PATCH v6 23/25] usb: chipidea: Pullup D+ in device mode via phy APIs Date: Wed, 28 Dec 2016 14:57:09 -0800 Message-Id: <20161228225711.698-24-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 In-Reply-To: <20161228225711.698-1-stephen.boyd@linaro.org> References: <20161228225711.698-1-stephen.boyd@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the phy supports it, call phy_set_mode() to pull up D+ when required by setting the mode to PHY_MODE_USB_DEVICE. If we want to remove the pullup, set the mode to PHY_MODE_USB_HOST. Cc: Peter Chen Cc: Greg Kroah-Hartman Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/udc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 0d532a724d48..6d61fa0689b0 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1609,10 +1610,15 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on) return 0; pm_runtime_get_sync(&ci->gadget.dev); - if (is_on) + if (is_on) { + if (ci->phy) + phy_set_mode(ci->phy, PHY_MODE_USB_DEVICE); hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS); - else + } else { hw_write(ci, OP_USBCMD, USBCMD_RS, 0); + if (ci->phy) + phy_set_mode(ci->phy, PHY_MODE_USB_HOST); + } pm_runtime_put_sync(&ci->gadget.dev); return 0;