rkcommon.h 1.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * (C) Copyright 2015 Google,  Inc
 * Written by Simon Glass <sjg@chromium.org>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#ifndef _RKCOMMON_H
#define _RKCOMMON_H

enum {
	RK_BLK_SIZE		= 512,
13 14
	RK_INIT_OFFSET		= 4,
	RK_MAX_BOOT_SIZE	= 512 << 10,
15 16 17 18
	RK_SPL_HDR_START	= RK_INIT_OFFSET * RK_BLK_SIZE,
	RK_SPL_HDR_SIZE		= 4,
	RK_SPL_START		= RK_SPL_HDR_START + RK_SPL_HDR_SIZE,
	RK_IMAGE_HEADER_LEN	= RK_SPL_START,
19 20
};

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/**
 * rkcommon_check_params() - check params
 *
 * @return 0 if OK, -1 if ERROR.
 */
int rkcommon_check_params(struct image_tool_params *params);

/**
 * rkcommon_get_spl_hdr() - get 4-bytes spl hdr for a Rockchip boot image
 *
 * Rockchip's bootrom requires the spl loader to start with a 4-bytes
 * header. The content of this header depends on the chip type.
 */
const char *rkcommon_get_spl_hdr(struct image_tool_params *params);

/**
 * rkcommon_get_spl_size() - get spl size for a Rockchip boot image
 *
 * Different chip may have different sram size. And if we want to jump
 * back to the bootrom after spl, we may need to reserve some sram space
 * for the bootrom.
 * The spl loader size should be sram size minus reserved size(if needed)
 */
int rkcommon_get_spl_size(struct image_tool_params *params);

46 47 48 49 50 51 52 53 54
/**
 * rkcommon_set_header() - set up the header for a Rockchip boot image
 *
 * This sets up a 2KB header which can be interpreted by the Rockchip boot ROM.
 *
 * @buf:	Pointer to header place (must be at least 2KB in size)
 * @file_size:	Size of the file we want the boot ROM to load, in bytes
 * @return 0 if OK, -ENOSPC if too large
 */
55 56
int rkcommon_set_header(void *buf, uint file_size,
			struct image_tool_params *params);
57 58

#endif