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: 9490777 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 EC14A62AB0 for ; Wed, 28 Dec 2016 23:02:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6EBD26242 for ; Wed, 28 Dec 2016 23:02:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA5F626419; Wed, 28 Dec 2016 23:02:45 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6681C26242 for ; Wed, 28 Dec 2016 23:02:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cMNDl-0004Dh-OG; Wed, 28 Dec 2016 23:01:21 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cMNAY-0001DH-4l for linux-arm-kernel@bombadil.infradead.org; Wed, 28 Dec 2016 22:58:02 +0000 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cMNAW-0003lF-Tx for linux-arm-kernel@lists.infradead.org; Wed, 28 Dec 2016 22:58:01 +0000 Received: by mail-pg0-x236.google.com with SMTP id g1so120721441pgn.0 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=KybFoz6MfYVdfUHdX89J7x/Ku/5tbgsA9MHkpKwNN3/YRKB5CYxKFKP+VJmFEIXuGy CwON1wSwPk36yNn8a8P8rr/Oq2wHQcSy5wan0ylr/4VSk5S3DEjytcc/hIaYf3AFq4MN Cj/T0iZrlblAVOMgpRrwh9rFcF+b2Bjkk+Y2kkiuvtKPAElkHf67036PMTFTzmbcUNlW fMLs481m7gSRdDSCbp8fXlAgovthjlPfqEB0x0fcvplsRk42rcn/v1XdXiQnEKoRzx/C qyPTDUhKvdoSenmNcxviWZvglDxsg0R9c8aodwS6w1z1UqYG0C+9YoNXht6jrirvLcho oX/A== X-Gm-Message-State: AIkVDXIDmFtetUuKo/8wpLETFP48AsjVve39/8guBSFiIrZSWZdMebSKzjnRBTHquH6lfYzB 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161228_175801_078985_9057E164 X-CRM114-Status: GOOD ( 13.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , Arnd Bergmann , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Peter Chen , Greg Kroah-Hartman , Andy Gross , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;