2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-07-19 13:16:59 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2016 Rockchip Electronics Co., Ltd
|
|
|
|
*/
|
2017-09-29 17:27:54 +00:00
|
|
|
|
2016-07-19 13:16:59 +00:00
|
|
|
#include <common.h>
|
2016-08-16 09:58:13 +00:00
|
|
|
#include <dm.h>
|
2022-11-10 09:19:16 +00:00
|
|
|
#include <efi_loader.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-03-28 03:01:23 +00:00
|
|
|
#include <asm/arch-rockchip/periph.h>
|
2022-11-10 09:19:16 +00:00
|
|
|
#include <linux/kernel.h>
|
2016-08-24 04:02:22 +00:00
|
|
|
#include <power/regulator.h>
|
2016-07-19 13:16:59 +00:00
|
|
|
|
2022-11-10 09:19:16 +00:00
|
|
|
#define ROCKPI4_UPDATABLE_IMAGES 2
|
|
|
|
|
2023-02-05 22:39:42 +00:00
|
|
|
#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
|
2022-11-10 09:19:16 +00:00
|
|
|
static struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0};
|
|
|
|
|
|
|
|
struct efi_capsule_update_info update_info = {
|
|
|
|
.images = fw_images,
|
|
|
|
};
|
|
|
|
|
|
|
|
u8 num_image_type_guids = ROCKPI4_UPDATABLE_IMAGES;
|
|
|
|
#endif
|
|
|
|
|
2019-07-22 12:02:18 +00:00
|
|
|
#ifndef CONFIG_SPL_BUILD
|
|
|
|
int board_early_init_f(void)
|
2016-07-19 13:16:59 +00:00
|
|
|
{
|
2019-06-21 20:57:20 +00:00
|
|
|
struct udevice *regulator;
|
2016-08-16 09:58:13 +00:00
|
|
|
int ret;
|
|
|
|
|
2016-08-24 04:02:22 +00:00
|
|
|
ret = regulator_get_by_platname("vcc5v0_host", ®ulator);
|
|
|
|
if (ret) {
|
|
|
|
debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = regulator_set_enable(regulator, true);
|
2019-07-22 12:02:18 +00:00
|
|
|
if (ret)
|
|
|
|
debug("%s vcc5v0-host-en set fail! ret %d\n", __func__, ret);
|
2016-08-24 04:02:22 +00:00
|
|
|
|
2016-08-16 09:58:13 +00:00
|
|
|
out:
|
2016-07-19 13:16:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-11-10 09:19:16 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION)
|
|
|
|
static bool board_is_rockpi_4b(void)
|
|
|
|
{
|
|
|
|
return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) &&
|
|
|
|
of_machine_is_compatible("radxa,rockpi4b");
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool board_is_rockpi_4c(void)
|
|
|
|
{
|
|
|
|
return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) &&
|
|
|
|
of_machine_is_compatible("radxa,rockpi4c");
|
|
|
|
}
|
|
|
|
|
|
|
|
void rockchip_capsule_update_board_setup(void)
|
|
|
|
{
|
|
|
|
if (board_is_rockpi_4b()) {
|
|
|
|
efi_guid_t idbldr_image_type_guid =
|
|
|
|
ROCKPI_4B_IDBLOADER_IMAGE_GUID;
|
|
|
|
efi_guid_t uboot_image_type_guid = ROCKPI_4B_UBOOT_IMAGE_GUID;
|
|
|
|
|
|
|
|
guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
|
|
|
|
guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
|
|
|
|
|
|
|
|
fw_images[0].fw_name = u"ROCKPI4B-IDBLOADER";
|
|
|
|
fw_images[1].fw_name = u"ROCKPI4B-UBOOT";
|
|
|
|
} else if (board_is_rockpi_4c()) {
|
|
|
|
efi_guid_t idbldr_image_type_guid =
|
|
|
|
ROCKPI_4C_IDBLOADER_IMAGE_GUID;
|
|
|
|
efi_guid_t uboot_image_type_guid = ROCKPI_4C_UBOOT_IMAGE_GUID;
|
|
|
|
|
|
|
|
guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
|
|
|
|
guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
|
|
|
|
|
|
|
|
fw_images[0].fw_name = u"ROCKPI4C-IDBLOADER";
|
|
|
|
fw_images[1].fw_name = u"ROCKPI4C-UBOOT";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT && CONFIG_EFI_PARTITION */
|
|
|
|
#endif /* !CONFIG_SPL_BUILD */
|