From patchwork Tue Dec 10 17:11:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11283041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E67A9112B for ; Tue, 10 Dec 2019 17:11:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BAC8B2073B for ; Tue, 10 Dec 2019 17:11:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="ckoe/WcJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727915AbfLJRL6 (ORCPT ); Tue, 10 Dec 2019 12:11:58 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:44680 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbfLJRL6 (ORCPT ); Tue, 10 Dec 2019 12:11:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1575997880; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2aUsQE1DKgvq3JL2eyia+DJerAH/OPdkjkm9YCiprVI=; b=ckoe/WcJW9nAej0d598EGa+W+KhVYQIfib3owkcpmcgkVEmMUw4QmFQbiwsRMB9kcAXoqS ETDTiS5Ssy3e0+KhVH6LAeooSTa+mYmgYFWLktO0MTo5K1y/zEwXUqvQ2rYOWcODvpmZvI 8DXNMhc7Q/vGd+TndWsgjgFOLOxUcWQ= From: Paul Cercueil To: Bin Liu , Greg Kroah-Hartman Cc: od@zcrc.me, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH v3 7/7] usb: musb: jz4740: Disable pullup at init Date: Tue, 10 Dec 2019 18:11:10 +0100 Message-Id: <20191210171110.62141-7-paul@crapouillou.net> In-Reply-To: <20191210171110.62141-1-paul@crapouillou.net> References: <20191210171110.62141-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The pullup may be already enabled before the driver is initialized. It has to be disabled at init time, as we cannot guarantee that a gadget driver will be bound to the UDC. Signed-off-by: Paul Cercueil --- Notes: v3: New patch drivers/usb/musb/jz4740.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c index f948eca654f3..1af9e4053312 100644 --- a/drivers/usb/musb/jz4740.c +++ b/drivers/usb/musb/jz4740.c @@ -75,6 +75,7 @@ static const struct musb_hdrc_config jz4740_musb_config = { static int jz4740_musb_init(struct musb *musb) { struct device *dev = musb->controller->parent; + u8 power; int err; if (dev->of_node) @@ -97,6 +98,14 @@ static int jz4740_musb_init(struct musb *musb) musb->isr = jz4740_musb_interrupt; musb->dma_share_usb_irq = true; + /* + * If the SoC booted from USB the pullup might still be set. + * Disable it until a gadget is bound. + */ + power = musb_readb(musb->mregs, MUSB_POWER); + power &= ~MUSB_POWER_SOFTCONN; + musb_writeb(musb->mregs, MUSB_POWER, power); + return 0; }