Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 |
| 3 | * Stefano Babic, DENX Software Engineering, sbabic@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #ifndef _IMXIMAGE_H_ |
| 25 | #define _IMXIMAGE_H_ |
| 26 | |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 27 | #include <config.h> |
| 28 | |
| 29 | #define MAX_HW_CFG_SIZE_V2 121 /* Max number of registers imx can set for v2 */ |
| 30 | #define MAX_HW_CFG_SIZE_V1 60 /* Max number of registers imx can set for v1 */ |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 31 | #define APP_CODE_BARKER 0xB1 |
| 32 | #define DCD_BARKER 0xB17219E9 |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 33 | |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 34 | #define HEADER_OFFSET 0x400 |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 35 | |
| 36 | #define CMD_DATA_STR "DATA" |
| 37 | #define FLASH_OFFSET_STANDARD 0x400 |
| 38 | #define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD |
| 39 | #define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD |
| 40 | #define FLASH_OFFSET_SPI FLASH_OFFSET_STANDARD |
| 41 | #define FLASH_OFFSET_ONENAND 0x100 |
| 42 | |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 43 | #define IVT_HEADER_TAG 0xD1 |
| 44 | #define IVT_VERSION 0x40 |
| 45 | #define DCD_HEADER_TAG 0xD2 |
| 46 | #define DCD_COMMAND_TAG 0xCC |
| 47 | #define DCD_VERSION 0x40 |
| 48 | #define DCD_COMMAND_PARAM 0x4 |
| 49 | |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 50 | enum imximage_cmd { |
| 51 | CMD_INVALID, |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 52 | CMD_IMAGE_VERSION, |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 53 | CMD_BOOT_FROM, |
| 54 | CMD_DATA |
| 55 | }; |
| 56 | |
| 57 | enum imximage_fld_types { |
| 58 | CFG_INVALID = -1, |
| 59 | CFG_COMMAND, |
| 60 | CFG_REG_SIZE, |
| 61 | CFG_REG_ADDRESS, |
| 62 | CFG_REG_VALUE |
| 63 | }; |
| 64 | |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 65 | enum imximage_version { |
| 66 | IMXIMAGE_VER_INVALID = -1, |
| 67 | IMXIMAGE_V1 = 1, |
| 68 | IMXIMAGE_V2 |
| 69 | }; |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 70 | |
| 71 | typedef struct { |
| 72 | uint32_t type; /* Type of pointer (byte, halfword, word, wait/read) */ |
| 73 | uint32_t addr; /* Address to write to */ |
| 74 | uint32_t value; /* Data to write */ |
| 75 | } dcd_type_addr_data_t; |
| 76 | |
| 77 | typedef struct { |
| 78 | uint32_t barker; /* Barker for sanity check */ |
| 79 | uint32_t length; /* Device configuration length (without preamble) */ |
| 80 | } dcd_preamble_t; |
| 81 | |
| 82 | typedef struct { |
| 83 | dcd_preamble_t preamble; |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 84 | dcd_type_addr_data_t addr_data[MAX_HW_CFG_SIZE_V1]; |
| 85 | } dcd_v1_t; |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 86 | |
| 87 | typedef struct { |
| 88 | uint32_t app_code_jump_vector; |
| 89 | uint32_t app_code_barker; |
| 90 | uint32_t app_code_csf; |
| 91 | uint32_t dcd_ptr_ptr; |
Stefano Babic | 5b28e91 | 2010-02-05 15:16:02 +0100 | [diff] [blame] | 92 | uint32_t super_root_key; |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 93 | uint32_t dcd_ptr; |
| 94 | uint32_t app_dest_ptr; |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 95 | } flash_header_v1_t; |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 96 | |
| 97 | typedef struct { |
| 98 | uint32_t length; /* Length of data to be read from flash */ |
| 99 | } flash_cfg_parms_t; |
| 100 | |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 101 | typedef struct { |
| 102 | flash_header_v1_t fhdr; |
| 103 | dcd_v1_t dcd_table; |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 104 | flash_cfg_parms_t ext_header; |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 105 | } imx_header_v1_t; |
| 106 | |
| 107 | typedef struct { |
| 108 | uint32_t addr; |
| 109 | uint32_t value; |
| 110 | } dcd_addr_data_t; |
| 111 | |
| 112 | typedef struct { |
| 113 | uint8_t tag; |
| 114 | uint16_t length; |
| 115 | uint8_t version; |
| 116 | } __attribute__((packed)) ivt_header_t; |
| 117 | |
| 118 | typedef struct { |
| 119 | uint8_t tag; |
| 120 | uint16_t length; |
| 121 | uint8_t param; |
| 122 | } __attribute__((packed)) write_dcd_command_t; |
| 123 | |
| 124 | typedef struct { |
| 125 | ivt_header_t header; |
| 126 | write_dcd_command_t write_dcd_command; |
| 127 | dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2]; |
| 128 | } dcd_v2_t; |
| 129 | |
| 130 | typedef struct { |
| 131 | uint32_t start; |
| 132 | uint32_t size; |
| 133 | uint32_t plugin; |
| 134 | } boot_data_t; |
| 135 | |
| 136 | typedef struct { |
| 137 | ivt_header_t header; |
| 138 | uint32_t entry; |
| 139 | uint32_t reserved1; |
| 140 | uint32_t dcd_ptr; |
| 141 | uint32_t boot_data_ptr; |
| 142 | uint32_t self; |
| 143 | uint32_t csf; |
| 144 | uint32_t reserved2; |
| 145 | } flash_header_v2_t; |
| 146 | |
| 147 | typedef struct { |
| 148 | flash_header_v2_t fhdr; |
| 149 | boot_data_t boot_data; |
| 150 | dcd_v2_t dcd_table; |
| 151 | } imx_header_v2_t; |
| 152 | |
| 153 | struct imx_header { |
| 154 | union { |
| 155 | imx_header_v1_t hdr_v1; |
| 156 | imx_header_v2_t hdr_v2; |
| 157 | } header; |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 158 | uint32_t flash_offset; |
| 159 | }; |
| 160 | |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 161 | typedef void (*set_dcd_val_t)(struct imx_header *imxhdr, |
| 162 | char *name, int lineno, |
| 163 | int fld, uint32_t value, |
| 164 | uint32_t off); |
| 165 | |
| 166 | typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr, |
| 167 | uint32_t dcd_len, |
| 168 | char *name, int lineno); |
| 169 | |
| 170 | typedef void (*set_imx_hdr_t)(struct imx_header *imxhdr, |
| 171 | uint32_t dcd_len, |
| 172 | struct stat *sbuf, |
| 173 | struct mkimage_params *params); |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 174 | |
| 175 | #endif /* _IMXIMAGE_H_ */ |