Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5812008ybl; Tue, 10 Dec 2019 11:54:21 -0800 (PST) X-Google-Smtp-Source: APXvYqwwD0hcFYSCU9V+PKiokZFs3pITD5r4g555EbTH/3v9Bn0h+sQoC7hkubXAIfAQ5OOHVbtO X-Received: by 2002:a9d:708f:: with SMTP id l15mr28508843otj.286.1576007661179; Tue, 10 Dec 2019 11:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576007661; cv=none; d=google.com; s=arc-20160816; b=pd4y5DqSpJYyoTB6Pw90CgXIQPh9k6RG/Hm7BFnp8Eab3pysA3KY5B+dIrORUk0Dyc NFsYaJFmGe/Nv1599PxH3tVhUUtw0Vc9QLK1Cb91mDorB/niedhYwI1dRKryeODSoBfX tbGPDxyDYCL24mNJotkxnOdrGWb7IYNOPedmjT0tPZqNOqgkdCXVeE+bWe/Q+tH2wsCd rFBeV25pGnhvD9I9q7m6JzX+FvxoaxJxfOL+6itghf2ye0OSJZk0CLGoNbYFv0rZY2Fk pcwehBRESXEq12fhlSSvoqTpqWd3lKofUHcLh0crjDbQyAANZsy5Gk4njwt30nU+kMpS w5jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=yo7sZxfjugdMo8ZFuedB2icaA5L7ymj3/COg0IqvRm0=; b=hvrDjxM4FKP0g58V/5aceCqdfquWCmhe0Gkeq2JiqlRfIr0vJrsR0wKKMra/IC9yVM umcuCmKQGMH/khU9V5aIR0mm+UclIAvialyaom50xQRYqvJfvNqr4JEBwrEUgEjQHX+s a0SleoyZZfjbSl+X2zasNbK2PLpXlqXqG4aGmdBi4zOYR9tYYoh9yoiNwyWvH26WSueT q32uQytezYCIplE5aloN9fNY/iSMZSHji5489Vnw/SH6IDaRahnEi9o4avxqRJTLaXvG INUF/HU7xmE2OuPouhOH7CKniB+pE2ULDOx9xweuGozw/DZ/qPlFT7ESiKQ5zT/Tsi+Y Uu1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Gt9zLh2w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si2587164oth.175.2019.12.10.11.54.08; Tue, 10 Dec 2019 11:54:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Gt9zLh2w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726743AbfLJTxK (ORCPT + 99 others); Tue, 10 Dec 2019 14:53:10 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35814 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbfLJTxK (ORCPT ); Tue, 10 Dec 2019 14:53:10 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBAJr32k029399; Tue, 10 Dec 2019 13:53:03 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576007584; bh=yo7sZxfjugdMo8ZFuedB2icaA5L7ymj3/COg0IqvRm0=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=Gt9zLh2wwit4Fz3gxo8h5LFl0P6nDAAQn8RSp5Ct9uDjRhN0aT3opw2Yuo+n1/XTm 9t2Fcrua7foIVe3OCoKtAZFz6d2XvqHwzc8p2zr9TocsuATjMmE0fjHf8IOE6UcsZO wEydWZWtxy74Gmd4DoXa2gbq9h0qZwgZHBRpzE24= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBAJr2oc100175; Tue, 10 Dec 2019 13:53:03 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 10 Dec 2019 13:53:03 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 10 Dec 2019 13:53:03 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBAJr3Qp054301; Tue, 10 Dec 2019 13:53:03 -0600 Date: Tue, 10 Dec 2019 13:52:30 -0600 From: Bin Liu To: Paul Cercueil CC: Greg Kroah-Hartman , , , Subject: Re: [PATCH v3 7/7] usb: musb: jz4740: Disable pullup at init Message-ID: <20191210195230.GA16429@iaqt7> Mail-Followup-To: Bin Liu , Paul Cercueil , Greg Kroah-Hartman , od@zcrc.me, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20191210171110.62141-1-paul@crapouillou.net> <20191210171110.62141-7-paul@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20191210171110.62141-7-paul@crapouillou.net> User-Agent: Mutt/1.9.4 (2018-02-28) X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Dec 10, 2019 at 06:11:10PM +0100, Paul Cercueil wrote: > 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; > } It is preferred the glue drivers don't touch the controller core registers if possible. Please try the following patch instead. -Bin. ------------- >8 ------------ t a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 683b719c5026..2f9105e8ea38 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2317,6 +2317,9 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) musb_disable_interrupts(musb); musb_writeb(musb->mregs, MUSB_DEVCTL, 0); + /* MUSB_POWER_SOFTCONN might be already set, jz4740 does this. */ + musb_writeb(musb->mregs, MUSB_POWER, 0); + /* Init IRQ workqueue before request_irq */ INIT_DELAYED_WORK(&musb->irq_work, musb_irq_work); INIT_DELAYED_WORK(&musb->deassert_reset_work, musb_deassert_reset);