blob: f56b379b937f68056122069cb5d884e703b9719b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kever Yang0d3d7832016-07-19 21:16:59 +08002/*
3 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
Kever Yang0d3d7832016-07-19 21:16:59 +08004 */
Philipp Tomsich3df66262017-09-29 19:27:54 +02005
Kever Yang0d3d7832016-07-19 21:16:59 +08006#include <common.h>
Kever Yang6d26c062016-08-16 17:58:13 +08007#include <dm.h>
Sughosh Ganud5d2e8d2022-11-10 14:49:16 +05308#include <efi_loader.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060010#include <log.h>
Kever Yang9fbe17c2019-03-28 11:01:23 +080011#include <asm/arch-rockchip/periph.h>
Sughosh Ganud5d2e8d2022-11-10 14:49:16 +053012#include <linux/kernel.h>
Kever Yangb1395292016-08-24 12:02:22 +080013#include <power/regulator.h>
Kever Yang0d3d7832016-07-19 21:16:59 +080014
Sughosh Ganud5d2e8d2022-11-10 14:49:16 +053015#define ROCKPI4_UPDATABLE_IMAGES 2
16
17#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT)
18static struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0};
19
20struct efi_capsule_update_info update_info = {
21 .images = fw_images,
22};
23
24u8 num_image_type_guids = ROCKPI4_UPDATABLE_IMAGES;
25#endif
26
Kever Yang804c9f12019-07-22 20:02:18 +080027#ifndef CONFIG_SPL_BUILD
28int board_early_init_f(void)
Kever Yang0d3d7832016-07-19 21:16:59 +080029{
Mark Kettenisc741f532019-06-21 22:57:20 +020030 struct udevice *regulator;
Kever Yang6d26c062016-08-16 17:58:13 +080031 int ret;
32
Kever Yangb1395292016-08-24 12:02:22 +080033 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);
Kever Yang804c9f12019-07-22 20:02:18 +080040 if (ret)
41 debug("%s vcc5v0-host-en set fail! ret %d\n", __func__, ret);
Kever Yangb1395292016-08-24 12:02:22 +080042
Kever Yang6d26c062016-08-16 17:58:13 +080043out:
Kever Yang0d3d7832016-07-19 21:16:59 +080044 return 0;
45}
Sughosh Ganud5d2e8d2022-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 */