From patchwork Thu Jun 15 19:07:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 1795581 X-Patchwork-Delegate: trini@ti.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=85.214.62.61; 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=cnN30lgp; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QhsHQ0XxNz20QH for ; Fri, 16 Jun 2023 05:07:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 264348617C; Thu, 15 Jun 2023 21:07:15 +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="cnN30lgp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A33D18617C; Thu, 15 Jun 2023 21:07:12 +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=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 8D11586140 for ; Thu, 15 Jun 2023 21:07:07 +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-il1-x133.google.com with SMTP id e9e14a558f8ab-341ce6fb1bfso4415275ab.2 for ; Thu, 15 Jun 2023 12:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686856026; x=1689448026; 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=VZUCM9H5mYFRZxZS3yWx7FVgQAu5r7KVuvJOnUdZYSs=; b=cnN30lgpR2nlLBrBJDgteWxu+u+KyWkiqvv3Dg0zWLe5z7ukYlMU8MSU08w+sAmfVx rtWYWUfVNt3GIT4oDz6abRyXFjdFWOKeO3r1u8x6RWpZDBNaayhieT/U5ybyspia/6N8 usJPwm74Mczmg9t0n4c89zNMJchcfp0yvW4QwgeazAnE1OyrhdQe/E9TKNP++L1DUUzi bWFGu7IxSkWthfqJec+XWhP2Xhmy0ZCYjrGmBb8s674TyBPZQNGSFLqi42V/EX/xJXvO mPV4LOeOfNDuNpoUdG4VLKWi6q5hKjgMH3Pw7GO1XhUBMHL8PRr12DtPSqxaayrMgN7+ 0hFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686856026; x=1689448026; 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=VZUCM9H5mYFRZxZS3yWx7FVgQAu5r7KVuvJOnUdZYSs=; b=YTKuX67t4XLDvsnDH9mmdA/sLNDYd1WjB/uqov0ue2EFSB6uf5prgNZIaALAIbC7TU zB+C15/IkQ3YfPLU99wksVipygim0mX88kLHNhMqzSSi+8/vp9mynoKpzrAXBhrXsLMF EfjIeNSINJlN/ws8uaR2F83ADvLEY5N9xZz61TucBt29lJnp9QgUOQB3K7XMtFTM/cTY AgHFrHx/HVoTItwRuyhGXOzJB/s+npB1DeObrPMEcegC/5VFJELEtrGw05QUHD5+X6V0 RttjNNcorjK5UW95fTkNTIJhKnEC9y+4ueW5Ehu7jEpnhKPDAI806eLFCltqCyrUT/1f ciIg== X-Gm-Message-State: AC+VfDxMOQ8MrIhrvTv6JUGV5wiwgeMLGCIs5DBGawr8HjFPG6b0Lhrt ySJcl3ejE10lUKK6+un+2DRI0mLs+aChDnkd X-Google-Smtp-Source: ACHHUZ6L6OMVWFQrgQriiuEVpH7TUmxw/F6oO7osWgdHo4dD4jcittsS9WI9BO5Dp6cg5jautkKgfA== X-Received: by 2002:a05:6e02:791:b0:335:7be2:26ca with SMTP id q17-20020a056e02079100b003357be226camr292919ils.19.1686856025996; Thu, 15 Jun 2023 12:07:05 -0700 (PDT) Received: from celestia.nettie.lan ([2001:470:42c4:101:b738:8cfc:8eb7:c069]) by smtp.gmail.com with ESMTPSA id o9-20020a92c689000000b0034095da6b5csm2224571ilg.80.2023.06.15.12.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 12:07:05 -0700 (PDT) From: Sam Edwards X-Google-Original-From: Sam Edwards To: u-boot@lists.denx.de Cc: Andre Przywara , Jagan Teki , Sam Edwards Subject: [PATCH v4 1/2] usb: musb-new: sunxi: only perform SRAM initialization when necessary Date: Thu, 15 Jun 2023 13:07:00 -0600 Message-Id: <20230615190701.327852-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615190701.327852-1-CFSworks@gmail.com> References: <20230615190701.327852-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 Only the older (ca. A10, A20) sunxis need this poke for the MUSB to function. Mimic the Linux kernel and add a `has_sram` flag to the config structure that is only set for the specific compatibles that require this initialization. Signed-off-by: Sam Edwards Reviewed-by: Andre Przywara Tested-by: Andre Przywara --- drivers/usb/musb-new/sunxi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index c5c63249aa..1111a67eaf 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -83,6 +83,7 @@ struct sunxi_musb_config { struct musb_hdrc_config *config; + bool has_sram; }; struct sunxi_glue { @@ -311,7 +312,10 @@ static int sunxi_musb_init(struct musb *musb) musb->isr = sunxi_musb_interrupt; - USBC_ConfigFIFO_Base(); + if (glue->cfg->has_sram) { + USBC_ConfigFIFO_Base(); + } + USBC_EnableDpDmPullUp(musb->mregs); USBC_EnableIdPullUp(musb->mregs); @@ -517,6 +521,7 @@ static int musb_usb_remove(struct udevice *dev) static const struct sunxi_musb_config sun4i_a10_cfg = { .config = &musb_config, + .has_sram = true, }; static const struct sunxi_musb_config sun6i_a31_cfg = { From patchwork Thu Jun 15 19:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 1795582 X-Patchwork-Delegate: trini@ti.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=NfiXv8Lh; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QhsHh12J5z20QH for ; Fri, 16 Jun 2023 05:07:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF3C4861C6; Thu, 15 Jun 2023 21:07:18 +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="NfiXv8Lh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CBCBD86140; Thu, 15 Jun 2023 21:07:12 +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=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 8BB0C86199 for ; Thu, 15 Jun 2023 21:07:08 +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-il1-x12b.google.com with SMTP id e9e14a558f8ab-340c1371fcfso7551285ab.1 for ; Thu, 15 Jun 2023 12:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686856027; x=1689448027; 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=S0g+a9hSpR/FnyiWmCTeBD4f3QBFL6+YkqZHZm+/lAw=; b=NfiXv8LhD0jXelmk+aOVuNhWiPUkuE57QyzkycrbZfqGs8JIVd/bJ3pskndbvWPnl/ MqjHgRa3b9TArdNZbLfFKLeEoVhNsSqXk0XU5af/PDfVuLd78N+zdGF0lTvLIUo2GEJO yOSRw3dJJHyfmbhunM5hntz7Yz7HMzMsNjKB4FW4B3koIEYVf4YOeU09socygX1+KFfx LndZps6MGmYc6r4HYM4ZCs8pcph/hX4v0ehOTAADJBRsgOl0+BqAxN1s+5zUgRKrMO0Q jv24rkZpXiiZ4/DHckCx02Yx2uOJ54+mItKc1a6Au+w3qmCwDH/cdHzOfEiuldsIovuq z4cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686856027; x=1689448027; 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=S0g+a9hSpR/FnyiWmCTeBD4f3QBFL6+YkqZHZm+/lAw=; b=I1EL3ZenSf9KiIzyIC02OM2BmRxt12W8yWh6swK5/zrlp99Gov8rJEvWVDOYm6xvUJ wbNF8M9HYip4Fti6/8RSJ2wT3Lyf52xjwlQQ4oZndgpCU2yMdm3LB1vN53V5CE4wF0QM Y0Gh0Ia7ugBdsiO/yvnxhUjFODampb6t+kq4Vsxmkky/jToLMON8syRGUnWdYkXit18N F5pM2z/3OZneYAMhPsRQuOqwMR0SkBpsfiFDviDMYHvu3X0Q10dmPgfkJc1aN6z0M67/ kB3uTc92mLc/movjXmKD1zgnxo/nyLbH/MssaLtooepDkqBou0+nKoryOE1kIjgWu35L ysBA== X-Gm-Message-State: AC+VfDyqAXxIUWItR+Uke4svmduJMW/AfwwgcXHDwkvFvIEo0LsqyshC Sd5s+vNIlmIMKYEtDacNvR3ysN+IcFTd/V9W X-Google-Smtp-Source: ACHHUZ4UsEt9wElJzmOwfLs6WZENMX59GaW2PIZbBvPacl/70ewLPwu4646xtgk9E/NsJaKpUTD96g== X-Received: by 2002:a92:d486:0:b0:335:5b3b:80 with SMTP id p6-20020a92d486000000b003355b3b0080mr232130ilg.30.1686856026987; Thu, 15 Jun 2023 12:07:06 -0700 (PDT) Received: from celestia.nettie.lan ([2001:470:42c4:101:b738:8cfc:8eb7:c069]) by smtp.gmail.com with ESMTPSA id o9-20020a92c689000000b0034095da6b5csm2224571ilg.80.2023.06.15.12.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 12:07:06 -0700 (PDT) From: Sam Edwards X-Google-Original-From: Sam Edwards To: u-boot@lists.denx.de Cc: Andre Przywara , Jagan Teki , Sam Edwards Subject: [PATCH v4 2/2] usb: musb-new: sunxi: clarify the purpose of SRAM initialization Date: Thu, 15 Jun 2023 13:07:01 -0600 Message-Id: <20230615190701.327852-3-CFSworks@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615190701.327852-1-CFSworks@gmail.com> References: <20230615190701.327852-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 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. Signed-off-by: Sam Edwards Reviewed-by: 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);