blob: d126a46a73c032766e53d24f787db64118e72921 [file] [log] [blame]
Stefano Babic7b07f092010-01-20 18:19:10 +01001/*
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-R643434aa360a2011-01-19 09:40:26 +000027#define MAX_HW_CFG_SIZE_V2 121 /* Max number of registers imx can set for v2 */
28#define MAX_HW_CFG_SIZE_V1 60 /* Max number of registers imx can set for v1 */
Stefano Babic7b07f092010-01-20 18:19:10 +010029#define APP_CODE_BARKER 0xB1
30#define DCD_BARKER 0xB17219E9
Stefano Babic7b07f092010-01-20 18:19:10 +010031
Liu Hui-R643434aa360a2011-01-19 09:40:26 +000032#define HEADER_OFFSET 0x400
Stefano Babic7b07f092010-01-20 18:19:10 +010033
34#define CMD_DATA_STR "DATA"
35#define FLASH_OFFSET_STANDARD 0x400
36#define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD
37#define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD
38#define FLASH_OFFSET_SPI FLASH_OFFSET_STANDARD
39#define FLASH_OFFSET_ONENAND 0x100
40
Liu Hui-R643434aa360a2011-01-19 09:40:26 +000041#define IVT_HEADER_TAG 0xD1
42#define IVT_VERSION 0x40
43#define DCD_HEADER_TAG 0xD2
44#define DCD_COMMAND_TAG 0xCC
45#define DCD_VERSION 0x40
46#define DCD_COMMAND_PARAM 0x4
47
Stefano Babic7b07f092010-01-20 18:19:10 +010048enum imximage_cmd {
49 CMD_INVALID,
Liu Hui-R643434aa360a2011-01-19 09:40:26 +000050 CMD_IMAGE_VERSION,
Stefano Babic7b07f092010-01-20 18:19:10 +010051 CMD_BOOT_FROM,
52 CMD_DATA
53};
54
55enum imximage_fld_types {
56 CFG_INVALID = -1,
57 CFG_COMMAND,
58 CFG_REG_SIZE,
59 CFG_REG_ADDRESS,
60 CFG_REG_VALUE
61};
62
Liu Hui-R643434aa360a2011-01-19 09:40:26 +000063enum imximage_version {
64 IMXIMAGE_VER_INVALID = -1,
65 IMXIMAGE_V1 = 1,
66 IMXIMAGE_V2
67};
Stefano Babic7b07f092010-01-20 18:19:10 +010068
69typedef struct {
70 uint32_t type; /* Type of pointer (byte, halfword, word, wait/read) */
71 uint32_t addr; /* Address to write to */
72 uint32_t value; /* Data to write */
73} dcd_type_addr_data_t;
74
75typedef struct {
76 uint32_t barker; /* Barker for sanity check */
77 uint32_t length; /* Device configuration length (without preamble) */
78} dcd_preamble_t;
79
80typedef struct {
81 dcd_preamble_t preamble;
Liu Hui-R643434aa360a2011-01-19 09:40:26 +000082 dcd_type_addr_data_t addr_data[MAX_HW_CFG_SIZE_V1];
83} dcd_v1_t;
Stefano Babic7b07f092010-01-20 18:19:10 +010084
85typedef struct {
86 uint32_t app_code_jump_vector;
87 uint32_t app_code_barker;
88 uint32_t app_code_csf;
89 uint32_t dcd_ptr_ptr;
Stefano Babic5cdde802010-02-05 15:16:02 +010090 uint32_t super_root_key;
Stefano Babic7b07f092010-01-20 18:19:10 +010091 uint32_t dcd_ptr;
92 uint32_t app_dest_ptr;
Liu Hui-R643434aa360a2011-01-19 09:40:26 +000093} flash_header_v1_t;
Stefano Babic7b07f092010-01-20 18:19:10 +010094
95typedef struct {
96 uint32_t length; /* Length of data to be read from flash */
97} flash_cfg_parms_t;
98
Liu Hui-R643434aa360a2011-01-19 09:40:26 +000099typedef struct {
100 flash_header_v1_t fhdr;
101 dcd_v1_t dcd_table;
Stefano Babic7b07f092010-01-20 18:19:10 +0100102 flash_cfg_parms_t ext_header;
Liu Hui-R643434aa360a2011-01-19 09:40:26 +0000103} imx_header_v1_t;
104
105typedef struct {
106 uint32_t addr;
107 uint32_t value;
108} dcd_addr_data_t;
109
110typedef struct {
111 uint8_t tag;
112 uint16_t length;
113 uint8_t version;
114} __attribute__((packed)) ivt_header_t;
115
116typedef struct {
117 uint8_t tag;
118 uint16_t length;
119 uint8_t param;
120} __attribute__((packed)) write_dcd_command_t;
121
122typedef struct {
123 ivt_header_t header;
124 write_dcd_command_t write_dcd_command;
125 dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2];
126} dcd_v2_t;
127
128typedef struct {
129 uint32_t start;
130 uint32_t size;
131 uint32_t plugin;
132} boot_data_t;
133
134typedef struct {
135 ivt_header_t header;
136 uint32_t entry;
137 uint32_t reserved1;
138 uint32_t dcd_ptr;
139 uint32_t boot_data_ptr;
140 uint32_t self;
141 uint32_t csf;
142 uint32_t reserved2;
143} flash_header_v2_t;
144
145typedef struct {
146 flash_header_v2_t fhdr;
147 boot_data_t boot_data;
148 dcd_v2_t dcd_table;
149} imx_header_v2_t;
150
151struct imx_header {
152 union {
153 imx_header_v1_t hdr_v1;
154 imx_header_v2_t hdr_v2;
155 } header;
Stefano Babic7b07f092010-01-20 18:19:10 +0100156 uint32_t flash_offset;
157};
158
Liu Hui-R643434aa360a2011-01-19 09:40:26 +0000159typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
160 char *name, int lineno,
161 int fld, uint32_t value,
162 uint32_t off);
163
164typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr,
165 uint32_t dcd_len,
166 char *name, int lineno);
167
168typedef void (*set_imx_hdr_t)(struct imx_header *imxhdr,
169 uint32_t dcd_len,
170 struct stat *sbuf,
171 struct mkimage_params *params);
Stefano Babic7b07f092010-01-20 18:19:10 +0100172
173#endif /* _IMXIMAGE_H_ */