1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd 4 */ 5 6 #ifndef _SPL_RKFW_H_ 7 #define _SPL_RKFW_H_ 8 9 #include <spl.h> 10 11 #define LOADER_HARD_STR "LOADER" 12 #ifdef CONFIG_SPL_ATF 13 #define TBOOT_HEAD_TAG 0x58334c42 /* 'B', 'L', '3', 'X' */ 14 #else 15 #define TBOOT_HEAD_TAG "TOS " 16 #endif 17 18 #define BL30_IMAGE_NAME "bl30.bin" /* SCP Firmware BL3-0 */ 19 #define BL31_IMAGE_NAME "bl31.bin" /* EL3 Runtime Firmware BL31 */ 20 #define BL32_IMAGE_NAME "bl32.bin" /* Secure Payload BL32 (Trusted OS) */ 21 22 #define UUID_SCP_FIRMWARE_BL30 0x30334c42 /* "BL30" */ 23 #define UUID_EL3_RUNTIME_FIRMWARE_BL31 0x31334c42 /* "BL31" */ 24 #define UUID_SECURE_PAYLOAD_BL32 0x32334c42 /* "BL32" */ 25 26 /* Signature size, unit is byte */ 27 #define SIGNATURE_SIZE 256 28 #define MAX_BL_CODE_NUM 6 29 #define LOADER_MAGIC_SIZE 8 30 #define LOADER_HASH_SIZE 32 31 32 /* Special value used to verify platform parameters from BL2 to BL3-1 */ 33 #define RK_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL 34 35 #ifdef CONFIG_MTD_NAND_CORE 36 #define RKFW_RETRY_SECTOR_SIZE 256 37 #define RKFW_RETRY_SECTOR_TIMES 32 38 #else 39 #define RKFW_RETRY_SECTOR_SIZE 1024 40 #define RKFW_RETRY_SECTOR_TIMES 8 41 #endif 42 43 struct s_fip_name_id { 44 const char *name; 45 const u32 id; 46 }; 47 48 typedef struct tag_tboot_header_2k { 49 u32 tag; 50 u32 version; 51 u32 flags; 52 u32 size; 53 u32 reserved1[4]; 54 u32 rsa_n[64]; 55 u32 rsa_e[64]; 56 u32 rsa_c[64]; 57 u32 reserved2[312]; 58 } tboot_header_2k, *ptboot_header_2k; 59 60 typedef struct tag_tboot_header { 61 u32 tag; 62 u32 version; 63 u32 flags; 64 u32 size; 65 u32 reserved[4]; 66 u32 rsa_n[64]; 67 u32 rsa_e[64]; 68 u32 rsa_c[64]; 69 } tboot_header, *ptboot_header; 70 71 typedef struct tag_boot_component { 72 u32 component_id; 73 u32 storage_addr; 74 u32 image_size; 75 u32 reserved; 76 } boot_component, *pboot_component; 77 78 typedef struct tag_component_data { 79 u32 hash_data[8]; 80 u32 load_addr; 81 u32 reserved[3]; 82 } component_data, *pcomponent_data; 83 84 typedef struct tag_tboot_entry { 85 boot_component component; 86 component_data compdata; 87 } tboot_entry, *ptboot_entry; 88 89 typedef struct tag_second_loader_hdr { 90 unsigned char magic[LOADER_MAGIC_SIZE]; 91 unsigned int version; 92 unsigned int reserved0; 93 unsigned int loader_load_addr; /* physical load addr ,default is 0x60000000 */ 94 unsigned int loader_load_size; /* size in bytes */ 95 unsigned int crc32; /* crc32 */ 96 unsigned int hash_len; /* 20 or 32 , 0 is no hash */ 97 unsigned char hash[LOADER_HASH_SIZE]; /* sha */ 98 unsigned int js_hash; /* js hsah */ 99 unsigned char reserved[1024-32-32-4]; 100 unsigned int sign_tag; /* 0x4E474953, 'N' 'G' 'I' 'S' */ 101 unsigned int sign_len; /* 256 */ 102 unsigned char rsa_hash[256]; 103 unsigned char reserved2[2048-1024-256-8]; 104 } second_loader_hdr; /* Size:2K */ 105 106 /** 107 * spl_load_rkfw_image - Load rockchip image(trust and U-Boot) and jump to bl31. 108 */ 109 int spl_load_rkfw_image(struct spl_image_info *spl_image, 110 struct spl_load_info *info); 111 #endif 112