Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B48D0EB64DB for ; Thu, 15 Jun 2023 10:33:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 909BF8630F; Thu, 15 Jun 2023 12:33:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 0C30886266; Thu, 15 Jun 2023 12:33:07 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id D47CB862CD for ; Thu, 15 Jun 2023 12:33:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 530AE1FB; Thu, 15 Jun 2023 03:33:47 -0700 (PDT) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 54BDF3F71E; Thu, 15 Jun 2023 03:33:02 -0700 (PDT) Date: Thu, 15 Jun 2023 11:32:58 +0100 From: Andre Przywara To: Sam Edwards Cc: u-boot@lists.denx.de, Jagan Teki , Marek Vasut Subject: Re: [PATCH v3 2/2] usb: musb-new: sunxi: clarify the purpose of SRAM initialization Message-ID: <20230615113258.12b11c9d@donnerap.cambridge.arm.com> In-Reply-To: <20230612200302.21354-3-CFSworks@gmail.com> References: <20230612200302.21354-1-CFSworks@gmail.com> <20230612200302.21354-3-CFSworks@gmail.com> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On Mon, 12 Jun 2023 14:03:02 -0600 Sam Edwards wrote: > This is largely a cosmetic change, with one functional distinction: > We are now only setting BIT(0), and no longer clearing BIT(1). > > The A20 manual confirms the purpose and bitwidth of this field, and we > have also been doing it this way for a while in Linux-land: The prior > narrative about this initialization being about configuring a FIFO has > pretty much been debunked for years now. > > This cleanup also adds a TODO comment about runtime discovery > of the SYSCON base, per discussion with Andre. > > Signed-off-by: Sam Edwards Reviewed-by: Andre Przywara Thanks for the changes! Cheers, Andre > Cc: Andre Przywara > --- > drivers/usb/musb-new/sunxi.c | 31 ++++++++++++++++++++++--------- > 1 file changed, 22 insertions(+), 9 deletions(-) > > diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c > index 1111a67eaf..a8b1a8f870 100644 > --- a/drivers/usb/musb-new/sunxi.c > +++ b/drivers/usb/musb-new/sunxi.c > @@ -171,15 +171,22 @@ static void USBC_ForceVbusValidToHigh(__iomem void *base) > musb_writel(base, USBC_REG_o_ISCR, reg_val); > } > > -static void USBC_ConfigFIFO_Base(void) > -{ > - u32 reg_value; > +/****************************************************************************** > + * Non-USBC register access needed for initialization > + ******************************************************************************/ > > - /* config usb fifo, 8kb mode */ > - reg_value = readl(SUNXI_SRAMC_BASE + 0x04); > - reg_value &= ~(0x03 << 0); > - reg_value |= BIT(0); > - writel(reg_value, SUNXI_SRAMC_BASE + 0x04); > +/* > + * A10(s), A13, GR8, A20: > + * switch ownership of SRAM block 'D' to the USB-OTG controller > + */ > +static void sunxi_musb_claim_sram(uintptr_t syscon_base) > +{ > + /* > + * BIT(0) of SRAM_CTRL_REG1 (syscon+0x04) controls SRAM-D ownership: > + * '0' -> exclusive access by CPU > + * '1' -> exclusive access by USB0 > + */ > + setbits_le32(syscon_base + 0x04, BIT(0)); > } > > /****************************************************************************** > @@ -313,7 +320,13 @@ static int sunxi_musb_init(struct musb *musb) > musb->isr = sunxi_musb_interrupt; > > if (glue->cfg->has_sram) { > - USBC_ConfigFIFO_Base(); > + /* > + * This is an older USB-OTG controller that Allwinner did not > + * endow with a dedicated SRAM block; it instead uses SRAM > + * block 'D', ownership of which needs to be handed over by > + * the CPU > + */ > + sunxi_musb_claim_sram(SUNXI_SRAMC_BASE); > } > > USBC_EnableDpDmPullUp(musb->mregs);