xref: /rk3399_rockchip-uboot/include/boot_rkimg.h (revision 4a2b8db466479ddec6ee85f9fe9d7f934016be9a)
1 /*
2  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #ifndef __BOOT_ROCKCHIP_H_
8 #define __BOOT_ROCKCHIP_H_
9 
10 /* This is a copy from Android boot loader */
11 enum _boot_mode {
12 	BOOT_MODE_NORMAL = 0,
13 	BOOT_MODE_RECOVERY,
14 	BOOT_MODE_BOOTLOADER,	/* Android: Fastboot mode */
15 	BOOT_MODE_LOADER,	/* Rockchip: Rockusb download mode */
16 	BOOT_MODE_CHARGING,
17 	BOOT_MODE_UMS,
18 	BOOT_MODE_BROM_DOWNLOAD,
19 	BOOT_MODE_PANIC,
20 	BOOT_MODE_WATCHDOG,
21 	BOOT_MODE_UNDEFINE,
22 };
23 
24 struct bootloader_message {
25 	char command[32];
26 	char status[32];
27 	char recovery[768];
28 	/*
29 	 * The 'recovery' field used to be 1024 bytes.  It has only ever
30 	 * been used to store the recovery command line, so 768 bytes
31 	 * should be plenty.  We carve off the last 256 bytes to store the
32 	 * stage string (for multistage packages) and possible future
33 	 * expansion.
34 	 */
35 	char stage[32];
36 	char slot_suffix[32];
37 	char reserved[192];
38 };
39 
40 struct rockchip_image {
41 	uint32_t tag;
42 	uint32_t size;
43 	int8_t image[1];
44 	uint32_t crc;
45 };
46 
47 #define RK_BLK_SIZE			512
48 #define TAG_KERNEL			0x4C4E524B
49 #define BCB_MESSAGE_BLK_OFFSET		(16 * 1024 >> 9)
50 
51 #define PART_UBOOT			"uboot"
52 #define PART_TRUST			"trust"
53 #define PART_MISC			"misc"
54 #define PART_RESOURCE			"resource"
55 #define PART_KERNEL			"kernel"
56 #define PART_BOOT			"boot"
57 #define PART_RECOVERY			"recovery"
58 #define PART_DTBO			"dtbo"
59 #define PART_LOGO			"logo"
60 
61 struct blk_desc *rockchip_get_bootdev(void);
62 void rockchip_set_bootdev(struct blk_desc *desc);
63 void board_run_recovery_wipe_data(void);
64 void setup_download_mode(void);
65 int rockchip_get_boot_mode(void);
66 int rockchip_read_dtb_file(void *fdt_addr);
67 int init_kernel_dtb(void);
68 
69 #endif
70