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 22DF0C43334 for ; Tue, 26 Jul 2022 09:09:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE4FC84144; Tue, 26 Jul 2022 11:09:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="dQjzpWhi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 769E584152; Tue, 26 Jul 2022 11:09:17 +0200 (CEST) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AC8CC84131 for ; Tue, 26 Jul 2022 11:09:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 26Q99BFt051878; Tue, 26 Jul 2022 04:09:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1658826551; bh=63DPRmVfcwEbnI/51WlHhnuiU9SQs6nBXASZ3NwLHxY=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=dQjzpWhiiEQ5Frb210kgjny3XvAVMdD8KLKNc7/3EWFu6smJFFxzyk/Rg952K9TxX jX8LY00XJ5iT3RyAiQ9gyBdrf8knQF4lDWkS4m+JcfNRwHf/7wFLvJPy3ByfcG7Im1 s35FrrBarFdv/fJ62ICwF+MWLKT0qfLtWWCicAq8= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 26Q99BRq067525 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 26 Jul 2022 04:09:11 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Tue, 26 Jul 2022 04:09:10 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Tue, 26 Jul 2022 04:09:10 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 26Q999TO120513; Tue, 26 Jul 2022 04:09:10 -0500 Date: Tue, 26 Jul 2022 14:39:09 +0530 From: Pratyush Yadav To: Xavier Drudis Ferran CC: , Jagan Teki , Vignesh R Subject: Re: [PATCH v3 3/4] spi-nor: Adapt soft reset to XTX25F32B in Rock Pi 4 rev 1.4 Message-ID: <20220726090909.jmeigghmh2atgbip@ti.com> References: <20220720153610.GD2049@begut> <20220720154237.GG2049@begut> <20220726071306.pvtuaauachpdvkyu@ti.com> <20220726082701.GA1772@begut> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20220726082701.GA1772@begut> X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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.6 at phobos.denx.de X-Virus-Status: Clean On 26/07/22 10:27AM, Xavier Drudis Ferran wrote: > > Thank you for your time looking at the patch. > > El Tue, Jul 26, 2022 at 12:43:06PM +0530, Pratyush Yadav deia: > > > > Please don't put the changelog in the commit message. Put it below the 3 > > dashed lines below. > > > > Sorry. Will try to remember it next time. Not sure there's a next version of > this patch, though. > > > > > This only tells if the _controller_ supports the op. There is no way to > > find out if the flash supports the op without reading SFDP, which would > > need you to either reset the flash or know which mode it is in. > > Correct. But you can't always read the SFDP if you get the flash in > some wrong state and try to reset it through a mode that the controller > doesn't support. > > > So this patch is all wrong. > > Then I won't send a 4th version unless someone else thinks it's worth > it and I have more time for it. > > > The only way to find out what the flash supports is to read its ID or > > SFDP. > > > > Chicken and egg ? The soft_reset is done before reading SFDP. > It was done always in octal mode before my patch ("always" means > whenever CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT was enabled). My > patch tries to do it in a mode that the controller supports. Yes, this is indeed a chicken and egg problem of sorts. The octal mode soft reset I added is a hack that gets _some_ flashes working but not all. I see 3 possible ways to solve this: 1. Encode soft reset type in device tree. Read DT to issue the correct type of reset. But if a flash supports multiple stateful modes like 4D-4D-4D and 8D-8D-8D, this might not work so well. 2. Do a hardware reset. This needs the RESET# line to be connected on the board and some way to toggle it. Does not work for boards that do not have this. 3. Discover the mode the flash is in. The SFDP spec (JESD216D-01) does recommend a way to do this in section "4.5 Command Modes". This can let us find out which type of soft reset command the flash takes by reading SFDP. Of course, this needs the flash to implement the read SFDP command in all modes, which is not mandatory as per spec (at least as per xSPI spec (JESD251), which documents 8D-8D-8D flashes). There is no one size fits all solution that I can see, so I think we need to do all 3 to get full coverage of all cases. But start with the one that fixes your use case and is easiest for you. I would guess that is point 2. And all this does not even fix the problem of flashes that do not support 1S-1S-1S mode at all. There are some flashes out there that simply only support 8D-8D-8D mode. For those flashes, a reset would still put them in 8D-8D-8D mode. To support those you need to discover the flash mode and then initialize the flash in that mode itself, without resetting. I would recommending working with the Linux SPI NOR subsystem first. That has more eyes looking at it so it would be easier to come up with a good solution. Then you can backport it to U-Boot. > > In my experiments this helps being able to program /dev/mtd0 from > linux with flashrom. If that is working in mainstream U-Boot on a Rock > Pi 4B version 1.4 or later (with XTX flash) for the rest of people, > then I must be testing wrong, what do I know? > > Thanks. Have a nice day. -- Regards, Pratyush Yadav Texas Instruments Inc.