rockchip: resource: fix/optimise some code logic

- alloc sysmem after load kernel dtb successfully;
- allow distro kernel dtb to be loaded later than other
  resource file, that is not controlled by code condition
  "if (list_empty(&entrys_head))".

Change-Id: If1657289a4f8980ad7d7a5df7da0e061aab21504
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-10-21 14:43:20 +08:00 committed by Jianhong Chen
parent bcf005ba08
commit 6069a2cc24
1 changed files with 17 additions and 18 deletions

View File

@ -845,22 +845,21 @@ int rockchip_read_dtb_file(void *fdt_addr)
char *dtb_name = DTB_FILE;
int size = -ENODEV;
if (list_empty(&entrys_head)) {
if (init_resource_list(NULL)) {
/* Load dtb from distro boot.img */
if (!get_file_info(NULL, dtb_name)) {
#ifdef CONFIG_ROCKCHIP_EARLY_DISTRO_DTB
/* Load dtb from distro boot.img */
printf("Distro DTB: %s\n",
CONFIG_ROCKCHIP_EARLY_DISTRO_DTB_PATH);
size = rockchip_read_distro_dtb_file(fdt_addr);
if (size < 0)
return size;
if (!sysmem_alloc_base(MEMBLK_ID_FDT,
(phys_addr_t)fdt_addr,
ALIGN(size, RK_BLK_SIZE) + CONFIG_SYS_FDT_PAD))
return -ENOMEM;
#endif
return size;
}
return -ENODEV;
}
/* Find dtb file according to hardware id(GPIO/ADC) */
@ -887,10 +886,6 @@ int rockchip_read_dtb_file(void *fdt_addr)
if (size < 0)
return size;
if (!sysmem_alloc_base(MEMBLK_ID_FDT, (phys_addr_t)fdt_addr,
ALIGN(size, RK_BLK_SIZE) + CONFIG_SYS_FDT_PAD))
return -ENOMEM;
size = rockchip_read_resource_file((void *)fdt_addr, dtb_name, 0, 0);
if (size < 0)
return size;
@ -900,6 +895,10 @@ int rockchip_read_dtb_file(void *fdt_addr)
return -EBADF;
}
if (!sysmem_alloc_base(MEMBLK_ID_FDT, (phys_addr_t)fdt_addr,
ALIGN(size, RK_BLK_SIZE) + CONFIG_SYS_FDT_PAD))
return -ENOMEM;
/* Apply DTBO */
#if defined(CONFIG_CMD_DTIMG) && defined(CONFIG_OF_LIBFDT_OVERLAY)
android_fdt_overlay_apply((void *)fdt_addr);