From patchwork Mon Jun 12 20:03: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: 1794056 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=jFqqz/MG; 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 4Qg2gP35vsz20Wl for ; Tue, 13 Jun 2023 06:03:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0E9B086128; Mon, 12 Jun 2023 22:03:19 +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="jFqqz/MG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9E9185F4F; Mon, 12 Jun 2023 22:03:10 +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-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (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 B7EFC85F79 for ; Mon, 12 Jun 2023 22:03: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-io1-xd2c.google.com with SMTP id ca18e2360f4ac-777b0cae9ecso304531339f.2 for ; Mon, 12 Jun 2023 13:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686600186; x=1689192186; 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=jFqqz/MGmElX0BviCN/GWARalvyJKy7+0IVX67zC3Q2gu8UATR2XCAt37q1mxThBxJ LsZ5fpYznOk3LtdFT9ds/FxwhmbvChFcg7P+zII1/F8WDSr+dVptDHv6LvUOZZlq6Nki dpTAaSFzQH5IrXQdDhfJlHeuD/kFApjUkJzJ6DMrQra1aHVRrnqSiiYyzzh3cc4JhbGO 03H0mCRcSuqsLXdyGdGxyo+PjST754cCEGIzhxRFmYaQpw1E9ndYz4vKNG/4dii3cbXV ahgzjV0bftrYBHyIAOalf37THJU4VYmocqSiduiUw54S+7r7DUaTcbyAbltiOq+E14b4 80Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686600186; x=1689192186; 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=aDVGizvnCyKCdQMR04Eg48kmybyCpqshJkKba3gyQWzuWRsBetU2y6AhPo93qIHafr QhJh4+OT7Lf4uE+QLSKMfYVkAORJjb1ljRaodpMCEKHhXXoh6TBYET8AJSXuBnnswyAk x5jPbX5ktzO9fvY9U6vzsyaKgBU+gVFgv4RU5yYex6HhKyDLNuLG2Mr8+nBGKuwZpqqd Ko45+UoeOLeSfEvbzIBjQAEIEG5rSEbqX99Mt1CtzGFXfoRG5zv9vAJHX0bHyBbQQQok LrCu+G43ZpfrTB3rAW4mb38bnwchHugFPNZMye/7cVPUXnDm6WDzfWuGQffJoGkm3DO4 Sp2w== X-Gm-Message-State: AC+VfDyYZk3sWv6w6IrMR6fyiZSTjfABfZco46oxOQiilB0mC0I972Iz xkoXHVwhQpbh86xY5sUWd6OB6JEr7uuDVJnI X-Google-Smtp-Source: ACHHUZ6iYyMk3O9fMNwTOYmkhVBUKasZTOId7tbl22V/WPmzxbKDhHvKo/wLbv0xZjWAbj2zz+aVEA== X-Received: by 2002:a5e:c017:0:b0:778:735c:9bed with SMTP id u23-20020a5ec017000000b00778735c9bedmr9330623iol.0.1686600186210; Mon, 12 Jun 2023 13:03:06 -0700 (PDT) Received: from celestia.nettie.lan ([2001:470:42c4:101:857:833a:c057:fc99]) by smtp.gmail.com with ESMTPSA id t5-20020a028785000000b0040fa5258658sm2925490jai.77.2023.06.12.13.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 13:03: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 v3 1/2] usb: musb-new: sunxi: only perform SRAM initialization when necessary Date: Mon, 12 Jun 2023 14:03:01 -0600 Message-Id: <20230612200302.21354-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230612200302.21354-1-CFSworks@gmail.com> References: <20230612200302.21354-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 Mon Jun 12 20:03:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 1794057 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=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=kruwmIFc; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qg2gh6qqSz20Wl for ; Tue, 13 Jun 2023 06:03:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 26DCB8617C; Mon, 12 Jun 2023 22:03:22 +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="kruwmIFc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0793B86168; Mon, 12 Jun 2023 22:03:13 +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-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 872FC85DFC for ; Mon, 12 Jun 2023 22:03: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-io1-xd2b.google.com with SMTP id ca18e2360f4ac-77807e43b7cso304845139f.1 for ; Mon, 12 Jun 2023 13:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686600187; x=1689192187; 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=0lteKZbxswIeVzBlhGKqfXdEKFNBAUHUOlQSt9L5m3I=; b=kruwmIFcNGcW7puj7qf0We9o1KvdAWAVpa9/h1Aopp0ANXdSlRdnQ+mowYtH1y3D+S G26yOXiNvMeXCEze25iyJkij7CJmdnOq1zdGmkckYPScqgf7VJEatKp7/yyLhTVh2Jt3 Q4VSZt6Bod1+WBBQBu924RoUHE6ud3fcd35tP7K90Z6d+CKht/TJ0uE6yVSpH+VFTDs9 w4qNbfSCVzeRSoGcVbepop6JP2/VCeolRro25YacvDEZyWnYzBDDW2I03NjOgiPByhCD WTuYt/NSohGOc4L3cIuIvai3+VmuIZ6b8CN2w9JIwri9fadB82U1owdO0Eub8PpSeKKD ihYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686600187; x=1689192187; 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=0lteKZbxswIeVzBlhGKqfXdEKFNBAUHUOlQSt9L5m3I=; b=Vvfy+SAC+v7SwCJf8w/IB52PzZXrd7K8NT00Kltipocw4UXxyMjCBjKG9QaJvvbyAk 8vso/AqeCS7zLDX1TMAHztpRost+hSuEzj+kNRVyb/C1o1VcprLVN2yxT/zRGouuzI0U 4egoKJONScghBoH/O/Y8xGWfMvqwKFIre4/JX1cChxYWdeSsQfPVLjb6QwsKQVdUb8lb doZAE4wwN9xKawXDlrxNy3BR4zxG9fkshZR30l7vPWDEMs4165Q9LzYSvjr75H8vnJ+T R4lYjXaPCrA6JdMMcSU8MtJdpezjN7dvetQKTvDYC4aNfHcKIUOt1jGJqEdPZItcaDAa dtTA== X-Gm-Message-State: AC+VfDxbrJhUSZmQo9kcqUHBtpL5dH2DCC6HYuR5nGvXhDH9Be1BSGLH jKKVVIUyxdoUyJlrEmQSURxrRJwjGEk/t6Tc X-Google-Smtp-Source: ACHHUZ6Us4yyAgITXbI5n+F+pKsn2BVJq6gv7pjOoQ6llI0oqEz1PTOty+YnjkE0yhVpipAQZ+2e9g== X-Received: by 2002:a5e:c10d:0:b0:774:8d99:184c with SMTP id v13-20020a5ec10d000000b007748d99184cmr9394201iol.11.1686600186873; Mon, 12 Jun 2023 13:03:06 -0700 (PDT) Received: from celestia.nettie.lan ([2001:470:42c4:101:857:833a:c057:fc99]) by smtp.gmail.com with ESMTPSA id t5-20020a028785000000b0040fa5258658sm2925490jai.77.2023.06.12.13.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 13:03: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 v3 2/2] usb: musb-new: sunxi: clarify the purpose of SRAM initialization Date: Mon, 12 Jun 2023 14:03:02 -0600 Message-Id: <20230612200302.21354-3-CFSworks@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230612200302.21354-1-CFSworks@gmail.com> References: <20230612200302.21354-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. 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 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);