blob: 214187bb8c5aa308760116524be4b126ceaf89ed [file] [log] [blame]
Stefano Babic8edcde52010-01-20 18:19:10 +01001/*
2 * (C) Copyright 2009
3 * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Stefano Babic8edcde52010-01-20 18:19:10 +01006 */
7
8#ifndef _IMXIMAGE_H_
9#define _IMXIMAGE_H_
10
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000011#define MAX_HW_CFG_SIZE_V2 121 /* Max number of registers imx can set for v2 */
12#define MAX_HW_CFG_SIZE_V1 60 /* Max number of registers imx can set for v1 */
Stefano Babic8edcde52010-01-20 18:19:10 +010013#define APP_CODE_BARKER 0xB1
14#define DCD_BARKER 0xB17219E9
Stefano Babic8edcde52010-01-20 18:19:10 +010015
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000016#define HEADER_OFFSET 0x400
Stefano Babic8edcde52010-01-20 18:19:10 +010017
Marek Vasut6cb83822013-04-25 10:16:02 +000018/*
19 * NOTE: This file must be kept in sync with arch/arm/include/asm/\
20 * imx-common/imximage.cfg because tools/imximage.c can not
21 * cross-include headers from arch/arm/ and vice-versa.
22 */
Stefano Babic8edcde52010-01-20 18:19:10 +010023#define CMD_DATA_STR "DATA"
Dirk Behme49d3e272012-02-22 22:50:19 +000024#define FLASH_OFFSET_UNDEFINED 0xFFFFFFFF
Stefano Babic8edcde52010-01-20 18:19:10 +010025#define FLASH_OFFSET_STANDARD 0x400
26#define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD
27#define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD
28#define FLASH_OFFSET_SPI FLASH_OFFSET_STANDARD
29#define FLASH_OFFSET_ONENAND 0x100
Dirk Behme19b409c2012-01-11 23:28:31 +000030#define FLASH_OFFSET_NOR 0x1000
31#define FLASH_OFFSET_SATA FLASH_OFFSET_STANDARD
Stefano Babic8edcde52010-01-20 18:19:10 +010032
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000033#define IVT_HEADER_TAG 0xD1
34#define IVT_VERSION 0x40
35#define DCD_HEADER_TAG 0xD2
36#define DCD_COMMAND_TAG 0xCC
37#define DCD_VERSION 0x40
38#define DCD_COMMAND_PARAM 0x4
39
Stefano Babic8edcde52010-01-20 18:19:10 +010040enum imximage_cmd {
41 CMD_INVALID,
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000042 CMD_IMAGE_VERSION,
Stefano Babic8edcde52010-01-20 18:19:10 +010043 CMD_BOOT_FROM,
Marek Vasut6cb83822013-04-25 10:16:02 +000044 CMD_BOOT_OFFSET,
Stefano Babic8edcde52010-01-20 18:19:10 +010045 CMD_DATA
46};
47
48enum imximage_fld_types {
49 CFG_INVALID = -1,
50 CFG_COMMAND,
51 CFG_REG_SIZE,
52 CFG_REG_ADDRESS,
53 CFG_REG_VALUE
54};
55
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000056enum imximage_version {
57 IMXIMAGE_VER_INVALID = -1,
58 IMXIMAGE_V1 = 1,
59 IMXIMAGE_V2
60};
Stefano Babic8edcde52010-01-20 18:19:10 +010061
62typedef struct {
63 uint32_t type; /* Type of pointer (byte, halfword, word, wait/read) */
64 uint32_t addr; /* Address to write to */
65 uint32_t value; /* Data to write */
66} dcd_type_addr_data_t;
67
68typedef struct {
69 uint32_t barker; /* Barker for sanity check */
70 uint32_t length; /* Device configuration length (without preamble) */
71} dcd_preamble_t;
72
73typedef struct {
74 dcd_preamble_t preamble;
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000075 dcd_type_addr_data_t addr_data[MAX_HW_CFG_SIZE_V1];
76} dcd_v1_t;
Stefano Babic8edcde52010-01-20 18:19:10 +010077
78typedef struct {
79 uint32_t app_code_jump_vector;
80 uint32_t app_code_barker;
81 uint32_t app_code_csf;
82 uint32_t dcd_ptr_ptr;
Stefano Babic5b28e912010-02-05 15:16:02 +010083 uint32_t super_root_key;
Stefano Babic8edcde52010-01-20 18:19:10 +010084 uint32_t dcd_ptr;
85 uint32_t app_dest_ptr;
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000086} flash_header_v1_t;
Stefano Babic8edcde52010-01-20 18:19:10 +010087
88typedef struct {
89 uint32_t length; /* Length of data to be read from flash */
90} flash_cfg_parms_t;
91
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000092typedef struct {
93 flash_header_v1_t fhdr;
94 dcd_v1_t dcd_table;
Stefano Babic8edcde52010-01-20 18:19:10 +010095 flash_cfg_parms_t ext_header;
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000096} imx_header_v1_t;
97
98typedef struct {
99 uint32_t addr;
100 uint32_t value;
101} dcd_addr_data_t;
102
103typedef struct {
104 uint8_t tag;
105 uint16_t length;
106 uint8_t version;
107} __attribute__((packed)) ivt_header_t;
108
109typedef struct {
110 uint8_t tag;
111 uint16_t length;
112 uint8_t param;
113} __attribute__((packed)) write_dcd_command_t;
114
115typedef struct {
116 ivt_header_t header;
117 write_dcd_command_t write_dcd_command;
118 dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2];
119} dcd_v2_t;
120
121typedef struct {
122 uint32_t start;
123 uint32_t size;
124 uint32_t plugin;
125} boot_data_t;
126
127typedef struct {
128 ivt_header_t header;
129 uint32_t entry;
130 uint32_t reserved1;
131 uint32_t dcd_ptr;
132 uint32_t boot_data_ptr;
133 uint32_t self;
134 uint32_t csf;
135 uint32_t reserved2;
136} flash_header_v2_t;
137
138typedef struct {
139 flash_header_v2_t fhdr;
140 boot_data_t boot_data;
141 dcd_v2_t dcd_table;
142} imx_header_v2_t;
143
Marek Vasut895d9962013-04-21 05:52:22 +0000144/* The header must be aligned to 4k on MX53 for NAND boot */
Liu Hui-R643438a1edd72011-01-19 09:40:26 +0000145struct imx_header {
146 union {
147 imx_header_v1_t hdr_v1;
148 imx_header_v2_t hdr_v2;
149 } header;
Stefano Babic8edcde52010-01-20 18:19:10 +0100150 uint32_t flash_offset;
Marek Vasut895d9962013-04-21 05:52:22 +0000151} __attribute__((aligned(4096)));
Stefano Babic8edcde52010-01-20 18:19:10 +0100152
Liu Hui-R643438a1edd72011-01-19 09:40:26 +0000153typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
154 char *name, int lineno,
155 int fld, uint32_t value,
156 uint32_t off);
157
158typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr,
159 uint32_t dcd_len,
160 char *name, int lineno);
161
Troy Kiskyad0826d2012-10-03 15:47:08 +0000162typedef void (*set_imx_hdr_t)(struct imx_header *imxhdr, uint32_t dcd_len,
163 uint32_t entry_point, uint32_t flash_offset);
Stefano Babic8edcde52010-01-20 18:19:10 +0100164
165#endif /* _IMXIMAGE_H_ */