mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
qca: spi-nor: Store the probe information to avoid unnecessary probes
Change-Id: If7260e4a4065d6406d9a8554f43853663f0e8f3b Signed-off-by: Santan Kumar <santank@codeaurora.org>
This commit is contained in:
parent
66f395836e
commit
a0dd6f4332
4 changed files with 19 additions and 9 deletions
|
|
@ -135,8 +135,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
|
||||||
|
|
||||||
flash = dev_get_uclass_priv(new);
|
flash = dev_get_uclass_priv(new);
|
||||||
#else
|
#else
|
||||||
if (flash)
|
spi_flash_free(flash);
|
||||||
spi_flash_free(flash);
|
|
||||||
|
|
||||||
new = spi_flash_probe(bus, cs, speed, mode);
|
new = spi_flash_probe(bus, cs, speed, mode);
|
||||||
flash = new;
|
flash = new;
|
||||||
|
|
|
||||||
|
|
@ -214,8 +214,6 @@ void sf_env_relocate_spec(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
err_read:
|
err_read:
|
||||||
spi_flash_free(env_flash);
|
|
||||||
env_flash = NULL;
|
|
||||||
out:
|
out:
|
||||||
free(tmp_env1);
|
free(tmp_env1);
|
||||||
free(tmp_env2);
|
free(tmp_env2);
|
||||||
|
|
@ -316,7 +314,6 @@ void sf_env_relocate_spec(void)
|
||||||
if (ret)
|
if (ret)
|
||||||
gd->env_valid = 1;
|
gd->env_valid = 1;
|
||||||
out:
|
out:
|
||||||
spi_flash_free(env_flash);
|
|
||||||
if (buf)
|
if (buf)
|
||||||
free(buf);
|
free(buf);
|
||||||
env_flash = NULL;
|
env_flash = NULL;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "sf_internal.h"
|
#include "sf_internal.h"
|
||||||
|
|
||||||
|
struct spi_flash *spi_flash_ptr[MAX_SF_BUS_NUM][MAX_SF_CS_NUM] = {NULL};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spi_flash_probe_slave() - Probe for a SPI flash device on a bus
|
* spi_flash_probe_slave() - Probe for a SPI flash device on a bus
|
||||||
*
|
*
|
||||||
|
|
@ -83,10 +85,16 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
|
||||||
{
|
{
|
||||||
struct spi_slave *bus;
|
struct spi_slave *bus;
|
||||||
|
|
||||||
|
if (spi_flash_ptr[busnum][cs] != NULL)
|
||||||
|
return spi_flash_ptr[busnum][cs];
|
||||||
|
|
||||||
bus = spi_setup_slave(busnum, cs, max_hz, spi_mode);
|
bus = spi_setup_slave(busnum, cs, max_hz, spi_mode);
|
||||||
if (!bus)
|
if (!bus)
|
||||||
return NULL;
|
return NULL;
|
||||||
return spi_flash_probe_tail(bus);
|
|
||||||
|
spi_flash_ptr[busnum][cs] = spi_flash_probe_tail(bus);
|
||||||
|
|
||||||
|
return spi_flash_ptr[busnum][cs];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_OF_SPI_FLASH
|
#ifdef CONFIG_OF_SPI_FLASH
|
||||||
|
|
@ -104,11 +112,15 @@ struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node,
|
||||||
|
|
||||||
void spi_flash_free(struct spi_flash *flash)
|
void spi_flash_free(struct spi_flash *flash)
|
||||||
{
|
{
|
||||||
|
if (flash) {
|
||||||
#ifdef CONFIG_SPI_FLASH_MTD
|
#ifdef CONFIG_SPI_FLASH_MTD
|
||||||
spi_flash_mtd_unregister();
|
spi_flash_mtd_unregister();
|
||||||
#endif
|
#endif
|
||||||
spi_free_slave(flash->spi);
|
spi_free_slave(flash->spi);
|
||||||
free(flash);
|
free(flash);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(spi_flash_ptr, NULL, sizeof(spi_flash_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* defined CONFIG_DM_SPI_FLASH */
|
#else /* defined CONFIG_DM_SPI_FLASH */
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#ifndef CONFIG_SF_DEFAULT_BUS
|
#ifndef CONFIG_SF_DEFAULT_BUS
|
||||||
# define CONFIG_SF_DEFAULT_BUS 0
|
# define CONFIG_SF_DEFAULT_BUS 0
|
||||||
#endif
|
#endif
|
||||||
|
#define MAX_SF_BUS_NUM 5
|
||||||
|
#define MAX_SF_CS_NUM 5
|
||||||
|
|
||||||
struct spi_slave;
|
struct spi_slave;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue