All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1] cmd/sf: probe flash with speed of last known flash or speed from devicetree
@ 2016-08-24 10:05 Hannes Schmelzer
  2016-08-24 10:35 ` Vignesh R
  0 siblings, 1 reply; 9+ messages in thread
From: Hannes Schmelzer @ 2016-08-24 10:05 UTC (permalink / raw)
  To: u-boot

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 <oe5hpm@oevsv.at>

---

 cmd/sf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/cmd/sf.c b/cmd/sf.c
index 286906c..9483806 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -87,6 +87,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
 	char *endp;
 #ifdef CONFIG_DM_SPI_FLASH
 	struct udevice *new, *bus_dev;
+	struct dm_spi_bus *spi;
 	int ret;
 	/* In DM mode defaults will be taken from DT */
 	speed = 0, mode = 0;
@@ -124,6 +125,15 @@ static int do_spi_flash_probe(int argc, char * const argv[])
 	/* Remove the old device, otherwise probe will just be a nop */
 	ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &new);
 	if (!ret) {
+		if (new != NULL) {
+			flash = dev_get_uclass_priv(new);
+			if (flash != NULL) {
+				speed = flash->spi->speed;
+			} else {
+				spi = dev_get_uclass_priv(bus_dev);
+				speed = spi->max_hz;
+			}
+		}
 		device_remove(new);
 		device_unbind(new);
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-08-25 10:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24 10:05 [U-Boot] [PATCH v1] cmd/sf: probe flash with speed of last known flash or speed from devicetree Hannes Schmelzer
2016-08-24 10:35 ` Vignesh R
2016-08-24 10:51   ` Hannes Schmelzer
2016-08-24 11:12     ` Vignesh R
2016-08-24 12:21       ` Hannes Schmelzer
2016-08-24 14:10         ` Hannes Schmelzer
2016-08-25  8:39           ` Vignesh R
2016-08-25  9:32             ` Hannes Schmelzer
2016-08-25 10:10               ` Vignesh R

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.