[PATCH v4 0/3] spi: spi_flash_probe_bus_cs() rely on DT for spi speed and mode

Patrice Chotard patrice.chotard at foss.st.com
Wed Mar 30 09:33:12 CEST 2022


Since commit e2e95e5e2542 ("spi: Update speed/mode on change")
when calling "sf probe" or "env save" on SPI flash,
spi_set_speed_mode() is called twice.

spi_get_bus_and_cs()
      |--> spi_claim_bus()
      |       |--> spi_set_speed_mode(speed and mode from DT)
      ...
      |--> spi_set_speed_mode(default speed and mode value)

The first spi_set_speed_mode() call is done with speed and mode
values from DT, whereas the second call is done with speed
and mode set to default value (speed is set to CONFIG_SF_DEFAULT_SPEED)

This is an issue because SPI flash performance are impacted by
using default speed which can be lower than the one defined in DT.

One solution is to set CONFIG_SF_DEFAULT_SPEED to the speed defined
in DT, but we loose flexibility offered by DT.

Another issue can be encountered with 2 SPI flashes using 2 different
speeds. In this specific case usage of CONFIG_SF_DEFAULT_SPEED is not
flexible compared to get the 2 different speeds from DT.


Changes in v4:
  - Split previous series in 3 patches
  - Update commit message with additionnal information

Changes in v3:
  - Update commit header to reflect what the patch really do.
  - Rename legacy spi_get_bus_and_cs() to _spi_get_bus_and_cs().
  - New spi_get_bus_and_cs() rely on DT for spi speed and mode values.
  - spi_flash_probe_bus_cs() rely also on DT for spi and mode values.

Changes in v2:
  - add spi_flash_probe_bus_cs_default() which calls spi_get_bus_and_cs()
    with "use_dt" param set to true, whereas spi_flash_probe_bus_cs() calls
    spi_get_bus_and_cs() with "use_dt" param set to true.

Patrice Chotard (3):
  spi: spi-uclass: Add new spi_get_bus_and_cs() implementation
  spi: spi_flash_probe_bus_cs() rely on DT for spi speed and mode
  test: dm: spi: Replace _spi_get_bus_and_cs() by spi_get_bus_and_cs()
    in some case

 board/CZ.NIC/turris_mox/turris_mox.c |  6 +--
 cmd/sf.c                             | 15 +++++--
 cmd/spi.c                            |  4 +-
 drivers/mtd/spi/sf-uclass.c          | 33 +++++++-------
 drivers/net/fm/fm.c                  |  4 +-
 drivers/net/pfe_eth/pfe_firmware.c   | 19 ++------
 drivers/net/sni_netsec.c             |  6 +--
 drivers/spi/spi-uclass.c             | 66 +++++++++++++++++++++++++---
 drivers/usb/gadget/max3420_udc.c     |  4 +-
 env/sf.c                             |  1 -
 include/spi.h                        | 19 +++++++-
 include/spi_flash.h                  |  1 -
 test/dm/spi.c                        | 33 +++++++-------
 13 files changed, 137 insertions(+), 74 deletions(-)

-- 
2.17.1



More information about the U-Boot mailing list