mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
ipq: Add entry to expose boot mode
Add environment variable in uboot and device-tree node in kernel as "flash_type" to expose current boot mode. Change-Id: I15d4547f135f187a157dd7b303fc31f2df77cec2 Signed-off-by: Pavithra Palanisamy <pavip@codeaurora.org>
This commit is contained in:
parent
33fa51cf26
commit
6ad227588f
4 changed files with 63 additions and 1 deletions
|
|
@ -429,6 +429,18 @@ int ipq_smem_get_boot_version(char *version_name, int buf_size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ipq_smem_get_boot_flash(uint32_t *flash_name)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = smem_read_alloc_entry(SMEM_BOOT_FLASH_TYPE,
|
||||
flash_name, sizeof(uint32_t));
|
||||
if (ret != 0)
|
||||
return -ENOMSG;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int smem_get_build_version(char *version_name, int buf_size, int index)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ enum {
|
|||
SMEM_BOOT_SDC_FLASH = 4,
|
||||
SMEM_BOOT_MMC_FLASH = 5,
|
||||
SMEM_BOOT_SPI_FLASH = 6,
|
||||
SMEM_BOOT_NORPLUSNAND = 7,
|
||||
SMEM_BOOT_NORPLUSEMMC = 8,
|
||||
};
|
||||
|
||||
struct version_entry
|
||||
|
|
@ -119,4 +121,5 @@ unsigned int get_mibib_active_partition(void);
|
|||
void qca_smem_part_to_mtdparts(char *mtdid, int len);
|
||||
int ipq_smem_get_socinfo_cpu_type(uint32_t *cpu_type);
|
||||
int ipq_smem_get_socinfo_version(uint32_t *version);
|
||||
int ipq_smem_get_boot_flash(uint32_t *flash_type);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -191,6 +191,33 @@ int board_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int get_current_flash_type(uint32_t *flash_type)
|
||||
{
|
||||
int ret;
|
||||
|
||||
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
|
||||
|
||||
/* get current boot mode from smem and set in env*/
|
||||
ret = ipq_smem_get_boot_flash(flash_type);
|
||||
if (ret) {
|
||||
printf("ipq: fdt fixup cannot get boot mode\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (*flash_type == SMEM_BOOT_SPI_FLASH) {
|
||||
if (get_which_flash_param("rootfs") ||
|
||||
sfi->flash_secondary_type == SMEM_BOOT_NAND_FLASH)
|
||||
*flash_type = SMEM_BOOT_NORPLUSNAND;
|
||||
else {
|
||||
if ((sfi->rootfs.offset == 0xBAD0FF5E) ||
|
||||
sfi->flash_secondary_type == SMEM_BOOT_MMC_FLASH)
|
||||
*flash_type = SMEM_BOOT_NORPLUSEMMC;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void get_kernel_fs_part_details(void)
|
||||
{
|
||||
int ret, i;
|
||||
|
|
@ -275,6 +302,9 @@ void board_flash_protect(void)
|
|||
int board_late_init(void)
|
||||
{
|
||||
unsigned int machid;
|
||||
uint32_t flash_type;
|
||||
int ret;
|
||||
|
||||
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
|
||||
|
||||
if (sfi->flash_type != SMEM_BOOT_MMC_FLASH) {
|
||||
|
|
@ -288,6 +318,12 @@ int board_late_init(void)
|
|||
setenv_addr("machid", (void *)machid);
|
||||
gd->bd->bi_arch_number = machid;
|
||||
}
|
||||
|
||||
/* get current boot mode from smem and set in env*/
|
||||
ret = get_current_flash_type(&flash_type);
|
||||
if (!ret)
|
||||
setenv_ulong("flash_type", (unsigned long)flash_type);
|
||||
|
||||
#ifdef CONFIG_FLASH_PROTECT
|
||||
board_flash_protect();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -494,10 +494,11 @@ int ft_board_setup(void *blob, bd_t *bd)
|
|||
u64 memory_start = CONFIG_SYS_SDRAM_BASE;
|
||||
u64 memory_size = gd->ram_size;
|
||||
unsigned long gmac_no;
|
||||
uint32_t flash_type;
|
||||
char *s;
|
||||
char *mtdparts = NULL;
|
||||
char parts_str[4096];
|
||||
int len = sizeof(parts_str);
|
||||
int len = sizeof(parts_str), ret;
|
||||
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
|
||||
int activepart = 0;
|
||||
struct flash_node_info nodes[] = {
|
||||
|
|
@ -552,6 +553,16 @@ int ft_board_setup(void *blob, bd_t *bd)
|
|||
debug("MTDIDS: %s\n", getenv("mtdids"));
|
||||
ipq_fdt_fixup_mtdparts(blob, nodes);
|
||||
}
|
||||
|
||||
/* Add "flash_type" to root node of the devicetree*/
|
||||
ret = get_current_flash_type(&flash_type);
|
||||
if (!ret) {
|
||||
ret = fdt_setprop(blob, 0, "flash_type", &flash_type,
|
||||
sizeof(flash_type));
|
||||
if (ret)
|
||||
printf("%s: cannot set flash type %d\n", __func__, ret);
|
||||
}
|
||||
|
||||
ipq_fdt_fixup_socinfo(blob);
|
||||
s = (getenv("gmacnumber"));
|
||||
if (s) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue