Hi Patrice,

On Mon, Mar 7, 2022 at 11:20 PM Patrice Chotard
<patrice.chot...@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.be...@nic.cz>
> Cc: Jagan Teki <ja...@amarulasolutions.com>
> Cc: Vignesh R <vigne...@ti.com>
> Cc: Joe Hershberger <joe.hershber...@ni.com>
> Cc: Ramon Fried <rfried....@gmail.com>
> Cc: Lukasz Majewski <lu...@denx.de>
> Cc: Marek Vasut <ma...@denx.de>
> Cc: Wolfgang Denk <w...@denx.de>
> Cc: Simon Glass <s...@chromium.org>
> Cc: Stefan Roese <s...@denx.de>
> Cc: "Pali Rohár" <p...@kernel.org>
> Cc: Konstantin Porotchkin <kos...@marvell.com>
> Cc: Igal Liberman <ig...@marvell.com>
> Cc: Bin Meng <bmeng...@gmail.com>
> Cc: Pratyush Yadav <p.ya...@ti.com>
> Cc: Sean Anderson <sean...@gmail.com>
> Cc: Anji J <anji.jagarlm...@nxp.com>
> Cc: Biwen Li <biwen...@nxp.com>
> Cc: Priyanka Jain <priyanka.j...@nxp.com>
> Cc: Chaitanya Sakinam <chaitanya.saki...@nxp.com>
>
> Signed-off-by: Patrice Chotard <patrice.chot...@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.

Reply via email to