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 2C1C4C7EE23 for ; Wed, 7 Jun 2023 05:39:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDA1F85F13; Wed, 7 Jun 2023 07:39:32 +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="TuLN0w5g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 31FD585D4E; Wed, 7 Jun 2023 07:39:31 +0200 (CEST) Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 19ABC85F13 for ; Wed, 7 Jun 2023 07:39:28 +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-xd33.google.com with SMTP id ca18e2360f4ac-77703f20aa9so226278639f.1 for ; Tue, 06 Jun 2023 22:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686116366; x=1688708366; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Uw/jq14HfrQGHlD88Cj+l9ySBhbH2Ai9aWSIAPzlM6g=; b=TuLN0w5gFVjvqkxcIY7rSxMyRFT8y+caqNvSXdUQbEiCh7aKYkRF3V1FsNnRU9dYLT tNIrOl5mKI3zBCQQZL+IckeHZqxx2l7uLTO+XqbDmMosAHXHtvXJkof+ogMuMh9U8ssg KqHKSTyJvbKcfXZ398hcNQ/0DRTxbnihoPWshdqsBVRaNAoULD3jQltpFimDP9WVvg9H kMQDVcJurNtESpPxCVs99Uksr7XblX9pJdNldQhmEor4SwlMsXA5LHKlZMYLEcMawY+R Bg2Szn1b0ppfeGin/+r88tb14N+QtX5/Zne0oUpcwIM8iyDpB+ayuzvHIbxxkAM1fNuP CowQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686116366; x=1688708366; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Uw/jq14HfrQGHlD88Cj+l9ySBhbH2Ai9aWSIAPzlM6g=; b=ClvkiovjobVQinPMe3TxihjVDglt55mOH72jhtd23kY6sTVxynPaypUH4VW6HcGpZd MWYBPLUc3h2ZnOhvXeKAeFc6NLssuoVaoMjW8+MvIormjEsCMRUkSPIL1fMiZ7K6UwXA RpPjQFwaLWsqgx5qGSZLJChC5kFqY0IZga+AKvDlTY7bWCf2pApoVYTOrjCxMMUZI6R4 lJaW79zKkSc0+OdcPk+TNWV+YXwAvSRBL8WzZHC99F64eJkLdWClOpYo/xZ0Dt/cJZ/D Hc3xoNJOEeR8h2oXMuYwtOXE1uoKsjDFkX+Pd9iiJJH1HxpfYNJYdp1nmbhFy3BPu3Do 3Dog== X-Gm-Message-State: AC+VfDytqfmeOgM1cUjGpBhjK0zSNAH8naIKT+FSP5Ich6HPMjVdkjWU KKX2O90D8DjtAgerrKRNQXo= X-Google-Smtp-Source: ACHHUZ4NtWNuCgyuN/VuvHyfJRCMflGrnYparTkDhIppkeyZl0iQBJHI9Z+H52Hn/Ld/X2WPlqJvBA== X-Received: by 2002:a5e:8345:0:b0:777:b1ac:30af with SMTP id y5-20020a5e8345000000b00777b1ac30afmr6158884iom.12.1686116366412; Tue, 06 Jun 2023 22:39:26 -0700 (PDT) Received: from ?IPV6:2001:470:42c4:101:2adc:3694:a494:b638? ([2001:470:42c4:101:2adc:3694:a494:b638]) by smtp.gmail.com with ESMTPSA id q18-20020a6b7112000000b007701de8bb96sm3529299iog.54.2023.06.06.22.39.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jun 2023 22:39:25 -0700 (PDT) Message-ID: Date: Tue, 6 Jun 2023 23:39:24 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 1/3] usb: musb-new: sunxi: do not attempt to access NULL SRAMC Content-Language: en-US To: Andre Przywara Cc: u-boot@lists.denx.de, Jagan Teki , Marek Vasut , Maksim Kiselev References: <20230602214958.167909-1-CFSworks@gmail.com> <20230602214958.167909-2-CFSworks@gmail.com> <20230605120424.7ed91fb4@donnerap.cambridge.arm.com> From: Sam Edwards In-Reply-To: <20230605120424.7ed91fb4@donnerap.cambridge.arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed 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 Howdy Andre, On 6/5/23 05:04, Andre Przywara wrote: > Ah, that's a good find, but I think it goes a bit deeper: > Just to be clear, "SRAMC" stands for "SRAM controller", not "SRAM memory > block C" (which other SoCs have, but indeed not the D1/T113s). However > we (sort of) have an "SRAM controller", although the manual and DT call > this IP block "syscon" these days. The address currently in ncat2.h is > just plain wrong, it's actually 0x3000000. I did understand SRAMC to mean "SRAM controller," but what a funny coincidence that NCAT2 does away with SRAM 'C' at around the same time I sent in this patch! I did not know it's now the "syscon," I just deduced that it wasn't being used for anything important when I couldn't find any relevant code relying on it. > So the code is already wrong, we should not touch SYSCON+0x04 for any > newer SoCs, based on the compatible. We seem to be just lucky that newer > syscons don't have any register at offset 0x4. > And using SUNXI_SRAMC_BASE is somewhat dodgy to begin with, we should use > the "allwinner,sram" property from the DT, although this is surely more > complicated. I spent longer than I thought I would looking into this! :) Adding a `has_sram` field to the match table data was easy enough, but dynamic discovery of the syscon is, for sure, more complicated. The biggest problem is that the data model for representing these bits seems overengineered for what it is, and most of the logic is just for identifying *which bit* needs to be set. Linux's logic for the "syscon base" part of it is just: the first allwinner,*-system-control device to probe, registers itself globally -- that's it. Surely we could keep the "set the 1 bit" part of it hardcoded and just do the same thing (global registration) for the syscon, no need to chase the allwinner,sram phandle? That should suffice if the goal is to remove the SUNXI_SRAMC_BASE define, no? (By the way, apparently this facility in the SYSCON+0x4 register is only 1 bit wide -- not 2 as U-Boot believes. It also seems to be for switching ownership of SRAM block 'D' between the USB controller and CPU, and if so the "config usb fifo, 8kb mode" comment and USBC_ConfigFIFO_Base function name are both wrong. I am only judging by the Linux implementation of this logic, though.) > Do you have spare cycles to convert this over to look at the DT for this > SRAM part? For now you might just change the SRAM address in ncat2.h to > 0x03000000, to be inline with the other SoCs. I'll do that latter part locally (can you take care of it in your series?) and send in a patch for the `has_sram` change that also clarifies the purpose of the syscon poke. The SUNXI_SRAMC_BASE removal I just now mentioned could be interesting, but not something I want to hold up NCAT2 support on. Best regards, Sam