mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
ipq807x: Add SF env support
Change-Id: I4ddf96b965e22c980a4c4ea02307afb361d639ec Signed-off-by: Sham Muthayyan <smuthayy@codeaurora.org>
This commit is contained in:
parent
46632823a3
commit
a60121fe0a
4 changed files with 48 additions and 38 deletions
|
|
@ -23,7 +23,9 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
extern int nand_env_device;
|
extern int nand_env_device;
|
||||||
extern env_t *nand_env_ptr;
|
extern env_t *nand_env_ptr;
|
||||||
extern char *nand_env_name_spec;
|
extern char *nand_env_name_spec;
|
||||||
|
extern char *sf_env_name_spec;
|
||||||
extern int nand_saveenv(void);
|
extern int nand_saveenv(void);
|
||||||
|
extern int sf_saveenv(void);
|
||||||
|
|
||||||
#ifdef CONFIG_QCA_MMC
|
#ifdef CONFIG_QCA_MMC
|
||||||
extern env_t *mmc_env_ptr;
|
extern env_t *mmc_env_ptr;
|
||||||
|
|
@ -134,18 +136,20 @@ int board_init(void)
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sfi->flash_type != SMEM_BOOT_MMC_FLASH) {
|
if (sfi->flash_type == SMEM_BOOT_SPI_FLASH) {
|
||||||
saveenv = nand_saveenv;
|
saveenv = sf_saveenv;
|
||||||
env_ptr = nand_env_ptr;
|
env_name_spec = sf_env_name_spec;
|
||||||
env_name_spec = nand_env_name_spec;
|
|
||||||
#ifdef CONFIG_QCA_MMC
|
#ifdef CONFIG_QCA_MMC
|
||||||
} else {
|
} else if (sfi->flash_type == SMEM_BOOT_MMC_FLASH) {
|
||||||
saveenv = mmc_saveenv;
|
saveenv = mmc_saveenv;
|
||||||
env_ptr = mmc_env_ptr;
|
env_ptr = mmc_env_ptr;
|
||||||
env_name_spec = mmc_env_name_spec;
|
env_name_spec = mmc_env_name_spec;
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
saveenv = nand_saveenv;
|
||||||
|
env_ptr = nand_env_ptr;
|
||||||
|
env_name_spec = nand_env_name_spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
ret = ipq_board_usb_init();
|
ret = ipq_board_usb_init();
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@
|
||||||
#include <environment.h>
|
#include <environment.h>
|
||||||
|
|
||||||
extern void nand_env_relocate_spec(void);
|
extern void nand_env_relocate_spec(void);
|
||||||
|
extern void sf_env_relocate_spec(void);
|
||||||
extern int nand_env_init(void);
|
extern int nand_env_init(void);
|
||||||
|
extern int sf_env_init(void);
|
||||||
|
|
||||||
#ifdef CONFIG_QCA_MMC
|
#ifdef CONFIG_QCA_MMC
|
||||||
extern int mmc_env_init(void);
|
extern int mmc_env_init(void);
|
||||||
|
|
@ -39,12 +41,14 @@ int env_init(void)
|
||||||
&sfi.flash_block_size,
|
&sfi.flash_block_size,
|
||||||
&sfi.flash_density);
|
&sfi.flash_density);
|
||||||
|
|
||||||
if (sfi.flash_type != SMEM_BOOT_MMC_FLASH) {
|
if (sfi.flash_type == SMEM_BOOT_SPI_FLASH) {
|
||||||
ret = nand_env_init();
|
ret = sf_env_init();
|
||||||
#ifdef CONFIG_QCA_MMC
|
#ifdef CONFIG_QCA_MMC
|
||||||
} else {
|
} else if (sfi.flash_type == SMEM_BOOT_MMC_FLASH) {
|
||||||
ret = mmc_env_init();
|
ret = mmc_env_init();
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
ret = nand_env_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -62,12 +66,14 @@ void env_relocate_spec(void)
|
||||||
|
|
||||||
if (sfi.flash_type == SMEM_BOOT_NO_FLASH) {
|
if (sfi.flash_type == SMEM_BOOT_NO_FLASH) {
|
||||||
set_default_env("!flashless boot");
|
set_default_env("!flashless boot");
|
||||||
} else if (sfi.flash_type != SMEM_BOOT_MMC_FLASH) {
|
} else if (sfi.flash_type == SMEM_BOOT_SPI_FLASH) {
|
||||||
nand_env_relocate_spec();
|
sf_env_relocate_spec();
|
||||||
#ifdef CONFIG_QCA_MMC
|
#ifdef CONFIG_QCA_MMC
|
||||||
} else {
|
} else if (sfi.flash_type == SMEM_BOOT_MMC_FLASH) {
|
||||||
mmc_env_relocate_spec();
|
mmc_env_relocate_spec();
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
nand_env_relocate_spec();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,12 @@ static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND;
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
char *env_name_spec = "SPI Flash";
|
char *sf_env_name_spec = "SPI Flash";
|
||||||
|
|
||||||
static struct spi_flash *env_flash;
|
static struct spi_flash *env_flash;
|
||||||
|
|
||||||
#if defined(CONFIG_ENV_OFFSET_REDUND)
|
#if defined(CONFIG_ENV_OFFSET_REDUND)
|
||||||
int saveenv(void)
|
int sf_saveenv(void)
|
||||||
{
|
{
|
||||||
env_t env_new;
|
env_t env_new;
|
||||||
char *saved_buffer = NULL, flag = OBSOLETE_FLAG;
|
char *saved_buffer = NULL, flag = OBSOLETE_FLAG;
|
||||||
|
|
@ -53,9 +53,9 @@ int saveenv(void)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!env_flash) {
|
if (!env_flash) {
|
||||||
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
|
env_flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
|
||||||
CONFIG_ENV_SPI_CS,
|
CONFIG_SF_DEFAULT_CS,
|
||||||
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
|
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE);
|
||||||
if (!env_flash) {
|
if (!env_flash) {
|
||||||
set_default_env("!spi_flash_probe() failed");
|
set_default_env("!spi_flash_probe() failed");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -134,7 +134,7 @@ int saveenv(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void env_relocate_spec(void)
|
void sf_env_relocate_spec(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int crc1_ok = 0, crc2_ok = 0;
|
int crc1_ok = 0, crc2_ok = 0;
|
||||||
|
|
@ -151,8 +151,8 @@ void env_relocate_spec(void)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
|
env_flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
|
||||||
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
|
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE);
|
||||||
if (!env_flash) {
|
if (!env_flash) {
|
||||||
set_default_env("!spi_flash_probe() failed");
|
set_default_env("!spi_flash_probe() failed");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -221,7 +221,7 @@ out:
|
||||||
free(tmp_env2);
|
free(tmp_env2);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int saveenv(void)
|
int sf_saveenv(void)
|
||||||
{
|
{
|
||||||
u32 saved_size, saved_offset, sector = 1;
|
u32 saved_size, saved_offset, sector = 1;
|
||||||
char *saved_buffer = NULL;
|
char *saved_buffer = NULL;
|
||||||
|
|
@ -229,9 +229,9 @@ int saveenv(void)
|
||||||
env_t env_new;
|
env_t env_new;
|
||||||
|
|
||||||
if (!env_flash) {
|
if (!env_flash) {
|
||||||
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
|
env_flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
|
||||||
CONFIG_ENV_SPI_CS,
|
CONFIG_SF_DEFAULT_CS,
|
||||||
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
|
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE);
|
||||||
if (!env_flash) {
|
if (!env_flash) {
|
||||||
set_default_env("!spi_flash_probe() failed");
|
set_default_env("!spi_flash_probe() failed");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -239,9 +239,9 @@ int saveenv(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is the sector larger than the env (i.e. embedded) */
|
/* Is the sector larger than the env (i.e. embedded) */
|
||||||
if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
|
if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_RANGE) {
|
||||||
saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE;
|
saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_RANGE;
|
||||||
saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE;
|
saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_RANGE;
|
||||||
saved_buffer = malloc(saved_size);
|
saved_buffer = malloc(saved_size);
|
||||||
if (!saved_buffer)
|
if (!saved_buffer)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -252,29 +252,28 @@ int saveenv(void)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CONFIG_ENV_SIZE > CONFIG_ENV_SECT_SIZE) {
|
if (CONFIG_ENV_RANGE > CONFIG_ENV_SECT_SIZE) {
|
||||||
sector = CONFIG_ENV_SIZE / CONFIG_ENV_SECT_SIZE;
|
sector = CONFIG_ENV_SIZE / CONFIG_ENV_SECT_SIZE;
|
||||||
if (CONFIG_ENV_SIZE % CONFIG_ENV_SECT_SIZE)
|
if (CONFIG_ENV_SIZE % CONFIG_ENV_SECT_SIZE)
|
||||||
sector++;
|
sector++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = env_export(&env_new);
|
ret = env_export(&env_new);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
puts("Erasing SPI flash...");
|
puts("Erasing SPI flash...");
|
||||||
ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET,
|
ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET,
|
||||||
sector * CONFIG_ENV_SECT_SIZE);
|
CONFIG_ENV_RANGE);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
puts("Writing to SPI flash...");
|
puts("Writing to SPI flash...");
|
||||||
ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET,
|
ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET,
|
||||||
CONFIG_ENV_SIZE, &env_new);
|
CONFIG_ENV_RANGE, &env_new);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) {
|
if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_RANGE) {
|
||||||
ret = spi_flash_write(env_flash, saved_offset,
|
ret = spi_flash_write(env_flash, saved_offset,
|
||||||
saved_size, saved_buffer);
|
saved_size, saved_buffer);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
@ -291,14 +290,14 @@ int saveenv(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void env_relocate_spec(void)
|
void sf_env_relocate_spec(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
|
buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
|
||||||
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
|
env_flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
|
||||||
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
|
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE);
|
||||||
if (!env_flash) {
|
if (!env_flash) {
|
||||||
set_default_env("!spi_flash_probe() failed");
|
set_default_env("!spi_flash_probe() failed");
|
||||||
if (buf)
|
if (buf)
|
||||||
|
|
@ -307,7 +306,7 @@ void env_relocate_spec(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = spi_flash_read(env_flash,
|
ret = spi_flash_read(env_flash,
|
||||||
CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf);
|
CONFIG_ENV_OFFSET, CONFIG_ENV_RANGE, buf);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
set_default_env("!spi_flash_read() failed");
|
set_default_env("!spi_flash_read() failed");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -324,7 +323,7 @@ out:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int env_init(void)
|
int sf_env_init(void)
|
||||||
{
|
{
|
||||||
/* SPI flash isn't usable before relocation */
|
/* SPI flash isn't usable before relocation */
|
||||||
gd->env_addr = (ulong)&default_environment[0];
|
gd->env_addr = (ulong)&default_environment[0];
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@
|
||||||
|
|
||||||
#define CONFIG_IPQ_FDT_HIGH 0x4A600000
|
#define CONFIG_IPQ_FDT_HIGH 0x4A600000
|
||||||
#define CONFIG_IPQ_NO_MACS 6
|
#define CONFIG_IPQ_NO_MACS 6
|
||||||
|
#define CONFIG_ENV_IS_IN_SPI_FLASH 1
|
||||||
|
#define CONFIG_ENV_SECT_SIZE (64 * 1024)
|
||||||
/*
|
/*
|
||||||
* IPQ_TFTP_MIN_ADDR: Starting address of Linux HLOS region.
|
* IPQ_TFTP_MIN_ADDR: Starting address of Linux HLOS region.
|
||||||
* CONFIG_TZ_END_ADDR: Ending address of Trust Zone and starting
|
* CONFIG_TZ_END_ADDR: Ending address of Trust Zone and starting
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue