From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vignesh R Date: Wed, 24 Aug 2016 16:42:34 +0530 Subject: [U-Boot] [PATCH v1] cmd/sf: probe flash with speed of last known flash or speed from devicetree In-Reply-To: <57BD7C19.4030401@schmelzer.or.at> References: <1472033154-31475-1-git-send-email-oe5hpm@oevsv.at> <86295f5e-70ad-e660-4ff4-2046e12a6780@ti.com> <57BD7C19.4030401@schmelzer.or.at> Message-ID: <196cb9a1-b5d9-f1bb-1d5a-ac2dfd2fe3a0@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wednesday 24 August 2016 04:21 PM, Hannes Schmelzer wrote: > On 08/24/2016 12:35 PM, Vignesh R wrote: >> Hi, > Hi Vignesh, >> On Wednesday 24 August 2016 03:35 PM, Hannes Schmelzer wrote: >>> During probing flashes on the spi bus using the "sf probe" command, a >>> maybe existing flash (from fdt) is unbound and removed to force the >>> 'spi_flash_probe_bus_cs' really scanning the bus. >>> >>> Today the bus is probed with speed 0, this triggers several fall-back >>> mechanism (mostly in the low-level drivers) to catch the impossible zero >>> speed. >>> Result of this is, that the spi-flash runs at very low speed depending >>> on the minimum given by low-level driver/hardware. >>> >>> Values like 'spi-max-frequency' from devicetree are ignored totally >>> today. >>> >>> This commit changes as following: >>> - if there was already some flash binding in devicetree (having some >>> spi-max-frequency within) speed is taken from it >>> - if no flash binding was present for speed the 'spi-max-frequency' from >>> the responsible spi node is taken. >>> >>> Signed-off-by: Hannes Schmelzer >> >> With commit 96907c0fe50a8 ("dm: spi: Read default speed and mode values >> from DT") sf probe picks spi-max-frequency from DT if not specified as >> argument. >> >> But when sf probe is called second time, the command fails to pick up >> speed from DT. This is because flash node is unbound from the SPI >> controller children nodes. Below patch should fix this issue: >> https://patchwork.ozlabs.org/patch/659979/ > > sry ... i didn't took notice about this patch at the beginning of mine. > Just reviewed and tested it. > > The named patch makes things a bit better but not good. > Speed for flash still has no relationship to 'spi-max-frequency' from > the spi-bus nor with a maybe defined flash in dts. > > Rather the #define CONFIG_ENV_SPI_MAX_HZ is used. > sf probe calls do_spi_flash_probe() -spi_flash_probe_bus_cs() -spi_get_bus_and_cs() In spi_get_bus_and_cs(): if (!speed) { speed = plat->max_hz; mode = plat->mode; } This should set speed to spi-max-frequency as per flash DT node. AFAIU, saveenv() uses CONFIG_ENV_SPI_MAX_HZ only when CONFIG_DM_SPI_FLASH is not defined. Could please explain how CONFIG_ENV_SPI_MAX_HZ takes precedence over spi-max-frequency during sf probe? -- Regards Vignesh