blob: 3c773d0930cc2b1bf8b1a0dedcb951e72392b56a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kever Yanga381bcf2016-07-19 21:16:59 +08002/*
3 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
Kever Yanga381bcf2016-07-19 21:16:59 +08004 */
Philipp Tomsichfb740642017-09-29 19:27:54 +02005
Kever Yanga381bcf2016-07-19 21:16:59 +08006#include <common.h>
Kever Yangad051382016-08-16 17:58:13 +08007#include <dm.h>
Sughosh Ganue86c7892022-11-10 14:49:16 +05308#include <efi_loader.h>
Simon Glass691d7192020-05-10 11:40:02 -06009#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060010#include <log.h>
Kever Yang15f09a12019-03-28 11:01:23 +080011#include <asm/arch-rockchip/periph.h>
Sughosh Ganue86c7892022-11-10 14:49:16 +053012#include <linux/kernel.h>
Kever Yang05c6e302016-08-24 12:02:22 +080013#include <power/regulator.h>
Kever Yanga381bcf2016-07-19 21:16:59 +080014
Sughosh Ganue86c7892022-11-10 14:49:16 +053015#define ROCKPI4_UPDATABLE_IMAGES 2
16
Simon Glass71aa8062023-02-05 15:39:42 -070017#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
Sughosh Ganue86c7892022-11-10 14:49:16 +053018static struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0};
19
20struct efi_capsule_update_info update_info = {
Masahisa Kojimacccea182023-06-07 14:41:51 +090021 .num_images = ROCKPI4_UPDATABLE_IMAGES,
Sughosh Ganue86c7892022-11-10 14:49:16 +053022 .images = fw_images,
23};
24
Sughosh Ganue86c7892022-11-10 14:49:16 +053025#endif
26
Kever Yang54b012f2019-07-22 20:02:18 +080027#ifndef CONFIG_SPL_BUILD
28int board_early_init_f(void)
29{
30 struct udevice *regulator;
31 int ret;
32
33 ret = regulator_get_by_platname("vcc5v0_host", &regulator);
34 if (ret) {
35 debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
36 goto out;
37 }
38
39 ret = regulator_set_enable(regulator, true);
40 if (ret)
41 debug("%s vcc5v0-host-en set fail! ret %d\n", __func__, ret);
42
43out:
44 return 0;
45}
Sughosh Ganue86c7892022-11-10 14:49:16 +053046
47#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION)
48static bool board_is_rockpi_4b(void)
49{
50 return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) &&
51 of_machine_is_compatible("radxa,rockpi4b");
52}
53
54static bool board_is_rockpi_4c(void)
55{
56 return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) &&
57 of_machine_is_compatible("radxa,rockpi4c");
58}
59
60void rockchip_capsule_update_board_setup(void)
61{
62 if (board_is_rockpi_4b()) {
63 efi_guid_t idbldr_image_type_guid =
64 ROCKPI_4B_IDBLOADER_IMAGE_GUID;
65 efi_guid_t uboot_image_type_guid = ROCKPI_4B_UBOOT_IMAGE_GUID;
66
67 guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
68 guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
69
70 fw_images[0].fw_name = u"ROCKPI4B-IDBLOADER";
71 fw_images[1].fw_name = u"ROCKPI4B-UBOOT";
72 } else if (board_is_rockpi_4c()) {
73 efi_guid_t idbldr_image_type_guid =
74 ROCKPI_4C_IDBLOADER_IMAGE_GUID;
75 efi_guid_t uboot_image_type_guid = ROCKPI_4C_UBOOT_IMAGE_GUID;
76
77 guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
78 guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
79
80 fw_images[0].fw_name = u"ROCKPI4C-IDBLOADER";
81 fw_images[1].fw_name = u"ROCKPI4C-UBOOT";
82 }
83}
84#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT && CONFIG_EFI_PARTITION */
85#endif /* !CONFIG_SPL_BUILD */