Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2016 Rockchip Electronics Co., Ltd |
Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 4 | */ |
Philipp Tomsich | fb74064 | 2017-09-29 19:27:54 +0200 | [diff] [blame] | 5 | |
Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 6 | #include <common.h> |
Kever Yang | ad05138 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 7 | #include <dm.h> |
Sughosh Ganu | e86c789 | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 8 | #include <efi_loader.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 11 | #include <asm/arch-rockchip/periph.h> |
Sughosh Ganu | e86c789 | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Kever Yang | 05c6e30 | 2016-08-24 12:02:22 +0800 | [diff] [blame] | 13 | #include <power/regulator.h> |
Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 14 | |
Sughosh Ganu | e86c789 | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 15 | #define ROCKPI4_UPDATABLE_IMAGES 2 |
| 16 | |
Simon Glass | 71aa806 | 2023-02-05 15:39:42 -0700 | [diff] [blame] | 17 | #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) |
Sughosh Ganu | e86c789 | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 18 | static struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0}; |
| 19 | |
| 20 | struct efi_capsule_update_info update_info = { |
Masahisa Kojima | cccea18 | 2023-06-07 14:41:51 +0900 | [diff] [blame] | 21 | .num_images = ROCKPI4_UPDATABLE_IMAGES, |
Sughosh Ganu | e86c789 | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 22 | .images = fw_images, |
| 23 | }; |
| 24 | |
Sughosh Ganu | e86c789 | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 25 | #endif |
| 26 | |
Kever Yang | 54b012f | 2019-07-22 20:02:18 +0800 | [diff] [blame] | 27 | #ifndef CONFIG_SPL_BUILD |
| 28 | int board_early_init_f(void) |
| 29 | { |
| 30 | struct udevice *regulator; |
| 31 | int ret; |
| 32 | |
| 33 | ret = regulator_get_by_platname("vcc5v0_host", ®ulator); |
| 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 | |
| 43 | out: |
| 44 | return 0; |
| 45 | } |
Sughosh Ganu | e86c789 | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 46 | |
| 47 | #if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION) |
| 48 | static bool board_is_rockpi_4b(void) |
| 49 | { |
| 50 | return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) && |
| 51 | of_machine_is_compatible("radxa,rockpi4b"); |
| 52 | } |
| 53 | |
| 54 | static bool board_is_rockpi_4c(void) |
| 55 | { |
| 56 | return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) && |
| 57 | of_machine_is_compatible("radxa,rockpi4c"); |
| 58 | } |
| 59 | |
| 60 | void 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 */ |