rockchip: board: add kernel dtb support
Load dtb from mmc/nand, rebuild live dt and scan dev. Change-Id: If079b23702d0df333b62a14fcf3f6c2c37d3d670 Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
parent
d2e8ba4eb0
commit
f8aaa2c25f
|
|
@ -361,6 +361,15 @@ config ROCKCHIP_VENDOR_PARTITION
|
||||||
This enable support to read/write vendor configuration data from/to
|
This enable support to read/write vendor configuration data from/to
|
||||||
this partition.
|
this partition.
|
||||||
|
|
||||||
|
config USING_KERNEL_DTB
|
||||||
|
bool "Using dtb from Kernel/resource for U-Boot"
|
||||||
|
depends on RKIMG_BOOTLOADER && OF_LIVE
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
This enable support to read dtb from resource and use it for U-Boot,
|
||||||
|
the uart and emmc will still using U-Boot dtb, but other devices like
|
||||||
|
regulator/pmic, display, usb will use dts node from kernel.
|
||||||
|
|
||||||
config ROCKCHIP_CRC
|
config ROCKCHIP_CRC
|
||||||
bool "Rockchip CRC verify images"
|
bool "Rockchip CRC verify images"
|
||||||
help
|
help
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@
|
||||||
#ifdef CONFIG_DRM_ROCKCHIP
|
#ifdef CONFIG_DRM_ROCKCHIP
|
||||||
#include <video_rockchip.h>
|
#include <video_rockchip.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <mmc.h>
|
||||||
|
#include <of_live.h>
|
||||||
|
#include <dm/root.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
|
@ -97,10 +100,66 @@ int board_late_init(void)
|
||||||
return rk_board_late_init();
|
return rk_board_late_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_USING_KERNEL_DTB
|
||||||
|
#include <asm/arch/resource_img.h>
|
||||||
|
#define DTB_FILE "rk-kernel.dtb"
|
||||||
|
int init_kernel_dtb(void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
struct mmc *mmc;
|
||||||
|
struct udevice *dev;
|
||||||
|
ulong fdt_addr = 0;
|
||||||
|
|
||||||
|
ret = mmc_initialize(gd->bd);
|
||||||
|
if (ret)
|
||||||
|
goto scan_nand;
|
||||||
|
mmc = find_mmc_device(0);
|
||||||
|
if (!mmc) {
|
||||||
|
printf("no mmc device at slot 0\n");
|
||||||
|
goto scan_nand;
|
||||||
|
}
|
||||||
|
ret = mmc_init(mmc);
|
||||||
|
if (!ret)
|
||||||
|
goto init_dtb;
|
||||||
|
printf("%s mmc init fail %d\n", __func__, ret);
|
||||||
|
scan_nand:
|
||||||
|
ret = uclass_get_device(UCLASS_RKNAND, 0, &dev);
|
||||||
|
if (ret) {
|
||||||
|
printf("%s: Cannot find rknand device\n", __func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
init_dtb:
|
||||||
|
fdt_addr = env_get_ulong("fdt_addr_r", 16, 0);
|
||||||
|
if (!fdt_addr) {
|
||||||
|
printf("No Found FDT Load Address.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = rockchip_read_resource_file((void *)fdt_addr, DTB_FILE, 0, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
printf("%s dtb in resource read fail\n", __func__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
of_live_build((void *)fdt_addr, (struct device_node **)&gd->of_root);
|
||||||
|
|
||||||
|
dm_scan_fdt((void *)fdt_addr, false);
|
||||||
|
|
||||||
|
gd->fdt_blob = (void *)fdt_addr;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int board_init(void)
|
int board_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#ifdef CONFIG_USING_KERNEL_DTB
|
||||||
|
init_kernel_dtb();
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_DM_REGULATOR
|
#ifdef CONFIG_DM_REGULATOR
|
||||||
ret = regulators_enable_boot_on(false);
|
ret = regulators_enable_boot_on(false);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue