1a131c1f4SSimon Glass /* 2a131c1f4SSimon Glass * (C) Copyright 2015 Google, Inc 3a131c1f4SSimon Glass * Written by Simon Glass <sjg@chromium.org> 4a131c1f4SSimon Glass * 5a131c1f4SSimon Glass * SPDX-License-Identifier: GPL-2.0+ 6a131c1f4SSimon Glass */ 7a131c1f4SSimon Glass 8a131c1f4SSimon Glass #ifndef _RKCOMMON_H 9a131c1f4SSimon Glass #define _RKCOMMON_H 10a131c1f4SSimon Glass 11a131c1f4SSimon Glass enum { 12a131c1f4SSimon Glass RK_BLK_SIZE = 512, 133641339eSJeffy Chen RK_INIT_OFFSET = 4, 143641339eSJeffy Chen RK_MAX_BOOT_SIZE = 512 << 10, 15*7bf274b9SJeffy Chen RK_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE, 16*7bf274b9SJeffy Chen RK_SPL_HDR_SIZE = 4, 17*7bf274b9SJeffy Chen RK_SPL_START = RK_SPL_HDR_START + RK_SPL_HDR_SIZE, 18*7bf274b9SJeffy Chen RK_IMAGE_HEADER_LEN = RK_SPL_START, 19a131c1f4SSimon Glass }; 20a131c1f4SSimon Glass 21a131c1f4SSimon Glass /** 22*7bf274b9SJeffy Chen * rkcommon_check_params() - check params 23*7bf274b9SJeffy Chen * 24*7bf274b9SJeffy Chen * @return 0 if OK, -1 if ERROR. 25*7bf274b9SJeffy Chen */ 26*7bf274b9SJeffy Chen int rkcommon_check_params(struct image_tool_params *params); 27*7bf274b9SJeffy Chen 28*7bf274b9SJeffy Chen /** 29*7bf274b9SJeffy Chen * rkcommon_get_spl_hdr() - get 4-bytes spl hdr for a Rockchip boot image 30*7bf274b9SJeffy Chen * 31*7bf274b9SJeffy Chen * Rockchip's bootrom requires the spl loader to start with a 4-bytes 32*7bf274b9SJeffy Chen * header. The content of this header depends on the chip type. 33*7bf274b9SJeffy Chen */ 34*7bf274b9SJeffy Chen const char *rkcommon_get_spl_hdr(struct image_tool_params *params); 35*7bf274b9SJeffy Chen 36*7bf274b9SJeffy Chen /** 37*7bf274b9SJeffy Chen * rkcommon_get_spl_size() - get spl size for a Rockchip boot image 38*7bf274b9SJeffy Chen * 39*7bf274b9SJeffy Chen * Different chip may have different sram size. And if we want to jump 40*7bf274b9SJeffy Chen * back to the bootrom after spl, we may need to reserve some sram space 41*7bf274b9SJeffy Chen * for the bootrom. 42*7bf274b9SJeffy Chen * The spl loader size should be sram size minus reserved size(if needed) 43*7bf274b9SJeffy Chen */ 44*7bf274b9SJeffy Chen int rkcommon_get_spl_size(struct image_tool_params *params); 45*7bf274b9SJeffy Chen 46*7bf274b9SJeffy Chen /** 47a131c1f4SSimon Glass * rkcommon_set_header() - set up the header for a Rockchip boot image 48a131c1f4SSimon Glass * 49a131c1f4SSimon Glass * This sets up a 2KB header which can be interpreted by the Rockchip boot ROM. 50a131c1f4SSimon Glass * 51a131c1f4SSimon Glass * @buf: Pointer to header place (must be at least 2KB in size) 52a131c1f4SSimon Glass * @file_size: Size of the file we want the boot ROM to load, in bytes 53a131c1f4SSimon Glass * @return 0 if OK, -ENOSPC if too large 54a131c1f4SSimon Glass */ 55*7bf274b9SJeffy Chen int rkcommon_set_header(void *buf, uint file_size, 56*7bf274b9SJeffy Chen struct image_tool_params *params); 57a131c1f4SSimon Glass 58a131c1f4SSimon Glass #endif 59