Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 |
| 3 | * Stefano Babic, DENX Software Engineering, sbabic@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef _IMXIMAGE_H_ |
| 9 | #define _IMXIMAGE_H_ |
| 10 | |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 11 | #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 Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 13 | #define APP_CODE_BARKER 0xB1 |
| 14 | #define DCD_BARKER 0xB17219E9 |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 15 | |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 16 | #define HEADER_OFFSET 0x400 |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 17 | |
Marek Vasut | d45fd73 | 2013-04-25 10:16:02 +0000 | [diff] [blame] | 18 | /* |
| 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 Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 23 | #define CMD_DATA_STR "DATA" |
Dirk Behme | 14a98cd | 2012-02-22 22:50:19 +0000 | [diff] [blame] | 24 | #define FLASH_OFFSET_UNDEFINED 0xFFFFFFFF |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 25 | #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 Behme | dfbf6ce | 2012-01-11 23:28:31 +0000 | [diff] [blame] | 30 | #define FLASH_OFFSET_NOR 0x1000 |
| 31 | #define FLASH_OFFSET_SATA FLASH_OFFSET_STANDARD |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 32 | |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 33 | #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 Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 40 | enum imximage_cmd { |
| 41 | CMD_INVALID, |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 42 | CMD_IMAGE_VERSION, |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 43 | CMD_BOOT_FROM, |
Marek Vasut | d45fd73 | 2013-04-25 10:16:02 +0000 | [diff] [blame] | 44 | CMD_BOOT_OFFSET, |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 45 | CMD_DATA |
| 46 | }; |
| 47 | |
| 48 | enum 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-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 56 | enum imximage_version { |
| 57 | IMXIMAGE_VER_INVALID = -1, |
| 58 | IMXIMAGE_V1 = 1, |
| 59 | IMXIMAGE_V2 |
| 60 | }; |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 61 | |
| 62 | typedef 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 | |
| 68 | typedef struct { |
| 69 | uint32_t barker; /* Barker for sanity check */ |
| 70 | uint32_t length; /* Device configuration length (without preamble) */ |
| 71 | } dcd_preamble_t; |
| 72 | |
| 73 | typedef struct { |
| 74 | dcd_preamble_t preamble; |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 75 | dcd_type_addr_data_t addr_data[MAX_HW_CFG_SIZE_V1]; |
| 76 | } dcd_v1_t; |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 77 | |
| 78 | typedef 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 Babic | 5cdde80 | 2010-02-05 15:16:02 +0100 | [diff] [blame] | 83 | uint32_t super_root_key; |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 84 | uint32_t dcd_ptr; |
| 85 | uint32_t app_dest_ptr; |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 86 | } flash_header_v1_t; |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 87 | |
| 88 | typedef struct { |
| 89 | uint32_t length; /* Length of data to be read from flash */ |
| 90 | } flash_cfg_parms_t; |
| 91 | |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 92 | typedef struct { |
| 93 | flash_header_v1_t fhdr; |
| 94 | dcd_v1_t dcd_table; |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 95 | flash_cfg_parms_t ext_header; |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 96 | } imx_header_v1_t; |
| 97 | |
| 98 | typedef struct { |
| 99 | uint32_t addr; |
| 100 | uint32_t value; |
| 101 | } dcd_addr_data_t; |
| 102 | |
| 103 | typedef struct { |
| 104 | uint8_t tag; |
| 105 | uint16_t length; |
| 106 | uint8_t version; |
| 107 | } __attribute__((packed)) ivt_header_t; |
| 108 | |
| 109 | typedef struct { |
| 110 | uint8_t tag; |
| 111 | uint16_t length; |
| 112 | uint8_t param; |
| 113 | } __attribute__((packed)) write_dcd_command_t; |
| 114 | |
| 115 | typedef 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 | |
| 121 | typedef struct { |
| 122 | uint32_t start; |
| 123 | uint32_t size; |
| 124 | uint32_t plugin; |
| 125 | } boot_data_t; |
| 126 | |
| 127 | typedef 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 | |
| 138 | typedef 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 Vasut | 3d1acc6 | 2013-04-21 05:52:22 +0000 | [diff] [blame] | 144 | /* The header must be aligned to 4k on MX53 for NAND boot */ |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 145 | struct imx_header { |
| 146 | union { |
| 147 | imx_header_v1_t hdr_v1; |
| 148 | imx_header_v2_t hdr_v2; |
| 149 | } header; |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 150 | uint32_t flash_offset; |
Marek Vasut | 3d1acc6 | 2013-04-21 05:52:22 +0000 | [diff] [blame] | 151 | } __attribute__((aligned(4096))); |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 152 | |
Liu Hui-R64343 | 4aa360a | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 153 | typedef 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 | |
| 158 | typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr, |
| 159 | uint32_t dcd_len, |
| 160 | char *name, int lineno); |
| 161 | |
Troy Kisky | 7bb9220 | 2012-10-03 15:47:08 +0000 | [diff] [blame] | 162 | typedef void (*set_imx_hdr_t)(struct imx_header *imxhdr, uint32_t dcd_len, |
| 163 | uint32_t entry_point, uint32_t flash_offset); |
Stefano Babic | 7b07f09 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 164 | |
| 165 | #endif /* _IMXIMAGE_H_ */ |