From patchwork Wed Jun 7 23:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 1791947 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=VJdcWH8Q; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qc3Cg3T6Mz20WP for ; Thu, 8 Jun 2023 09:17:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 993888609C; Thu, 8 Jun 2023 01:16:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VJdcWH8Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 390B38478A; Thu, 8 Jun 2023 01:16:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 08F7A84727 for ; Thu, 8 Jun 2023 01:16:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=cfsworks@gmail.com Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-777a8f11e14so58648039f.1 for ; Wed, 07 Jun 2023 16:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686179811; x=1688771811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o31RToXs+buj+zTR45+EnE17J4gujU+7Uxz6cC0AgM0=; b=VJdcWH8QDKLspDeiD5ATa5gv5JMqca4QSh64Ebb1nMKdKLXH8gfF7cS0X1zA6Dxtej OGVugw/sfki9HjaWOVNN1uVChukWqni4IDJOOLcLDiFl/BkyLeUqaebcvxZ+x6ousY30 O5y2hPiXwMuC4suSiV9KqJDmwtvuQFaSDaRl70cutlg5AX3LiThcS32qHfLPQxfbVIuT Ubq0YuqEj+kAxPx+ndSfIUpOeimSZQKLsIYVBaLwNbVbx1+wBwCJ7ulHipW+imrumOpR 3iz4nOD4A+BDJUfO/+6wEIK+TMfcbO4lZ6E6XJlGaHdCuMhaqrpwox6ae7cIOe2rudtZ 3nmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686179811; x=1688771811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o31RToXs+buj+zTR45+EnE17J4gujU+7Uxz6cC0AgM0=; b=GUbHwcrVugJYn3JJawP1puJBW0L6KVR59y4ysphnEIyORRBL2I50LDVnblmzKIoq8z ruendItSxzHJMx3ChlUlV6NJcpzBRNuQMS2AepMVT6I7NoyHlHBw6e0KoWQn4+6kvVFM MwbCiybIGYCSerb7XDfCo79Vi1iGkzVK2jXeXTa+2Dm9kqr/lK/AQWEZ/1zzlCKnqzHx ngEv5Yr1dLGVLxUtwAoZUPBQtdHsoOO5MhtlCV7X1Qva00ZRtS97R4cqdxGfjEBy8aFK X7FBabyiiz1Jg7/KCgfsAQ33m16sWNY/DoEJyfxRG9oBDJl2G0A8Iou0XiyE/MApxVja FXaw== X-Gm-Message-State: AC+VfDxZH3ggx9zp/LWi9uy2JO8OBbU0bFKbJG2Ue1licsg1XewkeFMa HujC1DtHaL23f0J+YrCPAdnkKJstRMOdPT4X X-Google-Smtp-Source: ACHHUZ5tK/vonxGsNqDXecRJpH92AgyRk4YLHmvmLaWXZXEKRwsPt4DqyLIAnpA1KFkcALbS0m2z+A== X-Received: by 2002:a05:6602:2770:b0:774:7b02:39ac with SMTP id l16-20020a056602277000b007747b0239acmr492748ioe.6.1686179811336; Wed, 07 Jun 2023 16:16:51 -0700 (PDT) Received: from celestia.nettie.lan ([2001:470:42c4:101:928e:2611:457e:59ff]) by smtp.gmail.com with ESMTPSA id g6-20020a0566380c4600b0040f7db6a264sm3560614jal.114.2023.06.07.16.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 16:16:50 -0700 (PDT) From: Sam Edwards X-Google-Original-From: Sam Edwards To: u-boot@lists.denx.de Cc: Andre Przywara , Jagan Teki , Marek Vasut , Sam Edwards Subject: [PATCH 2/2] usb: musb-new: sunxi: clarify the purpose of SRAM initialization Date: Wed, 7 Jun 2023 17:16:44 -0600 Message-Id: <20230607231644.28203-3-CFSworks@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607231644.28203-1-CFSworks@gmail.com> References: <20230607231644.28203-1-CFSworks@gmail.com> MIME-Version: 1.0 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 This is largely a cosmetic change, with one functional distinction: We are now only setting BIT(0), and no longer clearing BIT(1). The new comments and function name are not from any official source, but are updated to mirror how the Linux kernel sources treat this mystery magic bit. If we wanted to confirm that this speculation is correct, we could verify that SRAM-D is inaccessible whenever the bit is set, and then try clearing it again while the MUSB is in use to see what debris gets left behind in SRAM-D. This cleanup also adds a TODO comment about runtime discovery of the SYSCON base, per discussion with Andre. Signed-off-by: Sam Edwards Cc: Andre Przywara --- drivers/usb/musb-new/sunxi.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index c05c0d5561..2b954601a0 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -173,15 +173,23 @@ static void USBC_ForceVbusValidToHigh(__iomem void *base) musb_writel(base, USBC_REG_o_ISCR, reg_val); } -static void USBC_ConfigFIFO_Base(void) +/****************************************************************************** + * Non-USBC register access needed for initialization + ******************************************************************************/ + +/* A10(s), A13, GR8, A20: + * switch ownership of SRAM block 'D' to the USB-OTG controller */ +#define OFF_SUNXI_SRAMCTRL_D (0x04) +#define SUNXI_SRAMCTRL_D_FLAG_USBOTG BIT(0) + +static void sunxi_musb_claim_sram(void) { - u32 reg_value; + /* TODO: Do not use hardcoded SUNXI_SRAMC_BASE; find the syscon base by + * traversing this OTG device's `allwinner,sram` FDT property and + * working upward to the system controller. */ - /* 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); + setbits_le32(SUNXI_SRAMC_BASE + OFF_SUNXI_SRAMCTRL_D, + SUNXI_SRAMCTRL_D_FLAG_USBOTG); } /****************************************************************************** @@ -315,7 +323,11 @@ 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(); } USBC_EnableDpDmPullUp(musb->mregs);