Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kever Yang | 0d3d783 | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2016 Rockchip Electronics Co., Ltd |
Kever Yang | 0d3d783 | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 4 | */ |
Philipp Tomsich | 3df6626 | 2017-09-29 19:27:54 +0200 | [diff] [blame] | 5 | |
Kever Yang | 0d3d783 | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 6 | #include <common.h> |
Kever Yang | 6d26c06 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 7 | #include <dm.h> |
Sughosh Ganu | d5d2e8d | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 8 | #include <efi_loader.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Kever Yang | 9fbe17c | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 11 | #include <asm/arch-rockchip/periph.h> |
Sughosh Ganu | d5d2e8d | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Kever Yang | b139529 | 2016-08-24 12:02:22 +0800 | [diff] [blame] | 13 | #include <power/regulator.h> |
Kever Yang | 0d3d783 | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 14 | |
Sughosh Ganu | d5d2e8d | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 15 | #define ROCKPI4_UPDATABLE_IMAGES 2 |
| 16 | |
Simon Glass | b819621 | 2023-02-05 15:39:42 -0700 | [diff] [blame] | 17 | #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) |
Sughosh Ganu | d5d2e8d | 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 | 5d2438b | 2023-06-07 14:41:51 +0900 | [diff] [blame] | 21 | .num_images = ROCKPI4_UPDATABLE_IMAGES, |
Sughosh Ganu | d5d2e8d | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 22 | .images = fw_images, |
| 23 | }; |
| 24 | |
Sughosh Ganu | d5d2e8d | 2022-11-10 14:49:16 +0530 | [diff] [blame] | 25 | #endif |
| 26 | |
Kever Yang | 804c9f1 | 2019-07-22 20:02:18 +0800 | [diff] [blame] | 27 | #ifndef CONFIG_SPL_BUILD |
| 28 | int board_early_init_f(void) |
Kever Yang | 0d3d783 | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 29 | { |
Mark Kettenis | c741f53 | 2019-06-21 22:57:20 +0200 | [diff] [blame] | 30 | struct udevice *regulator; |
Kever Yang | 6d26c06 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 31 | int ret; |
| 32 | |
Kever Yang | b139529 | 2016-08-24 12:02:22 +0800 | [diff] [blame] | 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); |
Kever Yang | 804c9f1 | 2019-07-22 20:02:18 +0800 | [diff] [blame] | 40 | if (ret) |
| 41 | debug("%s vcc5v0-host-en set fail! ret %d\n", __func__, ret); |
Kever Yang | b139529 | 2016-08-24 12:02:22 +0800 | [diff] [blame] | 42 | |
Kever Yang | 6d26c06 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 43 | out: |
Kever Yang | 0d3d783 | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 44 | return 0; |
| 45 | } |
Sughosh Ganu | d5d2e8d | 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 */ |