[PATCH v3] spi: spi_flash_probe_bus_cs() rely on DT for spi speed and mode
Jagan Teki
jagan at amarulasolutions.com
Fri Mar 11 20:39:20 CET 2022
Hi Patrice,
On Mon, Mar 7, 2022 at 11:20 PM Patrice Chotard
<patrice.chotard at foss.st.com> wrote:
>
> 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.
>
> To fix this issue, the legacy spi_get_bus_and_cs() is renamed to
> _spi_get_bus_and_cs() and keep the same behaviour.
> Add a new spi_get_bus_and_cs() which rely on DT for spi speed and mode
> values.
>
> Now, spi_flash_probe_bus_cs() relies on DT for spi speed and mode
> and logically calls spi_get_bus_and_cs(). In case spi mode and speed are
> not read from DT, make usage of spi_flash_probe().
> This patch impacts the following :
> - cmd/sf.c: if spi mode and/or speed is passed in argument, call
> spi_flash_probe() otherwise call spi_flash_probe_bus_cs().
>
> _ cmd/spi.c: keep legacy, replace spi_get_bus_and_cs() by
> _spi_get_bus_and_cs()
>
> _ drivers/net/fm/fm.c: no impact as by default spi speed and mode
> was set to 0 and a comment indicates that speed and mode are read
> from DT.
>
> _ drivers/net/pfe_eth/pfe_firmware.c: spi speed and mode are not read
> from DT by all platforms using this driver, so keep legacy and replace
> spi_flash_probe_bus_cs() by spi_flash_probe();
>
> _ drivers/usb/gadget/max3420_udc.c: spi speed and mode are not read
> from DT, keep legacy, replace spi_get_bus_and_cs() by
> _spi_get_bus_and_cs()
>
> _ drivers/net/sni_netsec.c : spi speed and mode are not read from DT,
> so replace spi_flash_probe_bus_cs() by spi_flash_probe().
>
> _ drivers/usb/gadget/max3420_udc.c: Can't find any platform which make
> usage of this driver, nevertheless, keep legacy and replace
> spi_get_bus_and_cs() by _spi_get_bus_and_cs().
>
> _ env/sf.c: no impact, as by default spi speed and mode
> was set to 0 and a comment indicates that speed and mode are read
> from DT.
>
> - update test/dm/spi.c: when spi_get_bus_and_cs() was used wihtout
> driver and device name, no change.
> When spi_get_bus_and_cs() was used with driver and device name,
> use the legacy by calling _spi_get_bus_and_cs().
>
> Cc: Marek Behun <marek.behun at nic.cz>
> Cc: Jagan Teki <jagan at amarulasolutions.com>
> Cc: Vignesh R <vigneshr at ti.com>
> Cc: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Ramon Fried <rfried.dev at gmail.com>
> Cc: Lukasz Majewski <lukma at denx.de>
> Cc: Marek Vasut <marex at denx.de>
> Cc: Wolfgang Denk <wd at denx.de>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Stefan Roese <sr at denx.de>
> Cc: "Pali Rohár" <pali at kernel.org>
> Cc: Konstantin Porotchkin <kostap at marvell.com>
> Cc: Igal Liberman <igall at marvell.com>
> Cc: Bin Meng <bmeng.cn at gmail.com>
> Cc: Pratyush Yadav <p.yadav at ti.com>
> Cc: Sean Anderson <seanga2 at gmail.com>
> Cc: Anji J <anji.jagarlmudi at nxp.com>
> Cc: Biwen Li <biwen.li at nxp.com>
> Cc: Priyanka Jain <priyanka.jain at nxp.com>
> Cc: Chaitanya Sakinam <chaitanya.sakinam at nxp.com>
>
> Signed-off-by: Patrice Chotard <patrice.chotard at foss.st.com>
> ---
Look like this patch combined many changes together, please separate
it and send it as a series that would help to review propperly.
Thanks,
Jagan.
More information about the U-Boot
mailing list