imximage.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. #ifndef _IMXIMAGE_H_
  24. #define _IMXIMAGE_H_
  25. #define MAX_HW_CFG_SIZE_V2 121 /* Max number of registers imx can set for v2 */
  26. #define MAX_HW_CFG_SIZE_V1 60 /* Max number of registers imx can set for v1 */
  27. #define APP_CODE_BARKER 0xB1
  28. #define DCD_BARKER 0xB17219E9
  29. #define HEADER_OFFSET 0x400
  30. /*
  31. * NOTE: This file must be kept in sync with arch/arm/include/asm/\
  32. * imx-common/imximage.cfg because tools/imximage.c can not
  33. * cross-include headers from arch/arm/ and vice-versa.
  34. */
  35. #define CMD_DATA_STR "DATA"
  36. #define FLASH_OFFSET_UNDEFINED 0xFFFFFFFF
  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. #define FLASH_OFFSET_NOR 0x1000
  43. #define FLASH_OFFSET_SATA FLASH_OFFSET_STANDARD
  44. #define IVT_HEADER_TAG 0xD1
  45. #define IVT_VERSION 0x40
  46. #define DCD_HEADER_TAG 0xD2
  47. #define DCD_COMMAND_TAG 0xCC
  48. #define DCD_VERSION 0x40
  49. #define DCD_COMMAND_PARAM 0x4
  50. enum imximage_cmd {
  51. CMD_INVALID,
  52. CMD_IMAGE_VERSION,
  53. CMD_BOOT_FROM,
  54. CMD_BOOT_OFFSET,
  55. CMD_DATA
  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. enum imximage_version {
  65. IMXIMAGE_VER_INVALID = -1,
  66. IMXIMAGE_V1 = 1,
  67. IMXIMAGE_V2
  68. };
  69. typedef 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. typedef struct {
  75. uint32_t barker; /* Barker for sanity check */
  76. uint32_t length; /* Device configuration length (without preamble) */
  77. } dcd_preamble_t;
  78. typedef struct {
  79. dcd_preamble_t preamble;
  80. dcd_type_addr_data_t addr_data[MAX_HW_CFG_SIZE_V1];
  81. } dcd_v1_t;
  82. typedef struct {
  83. uint32_t app_code_jump_vector;
  84. uint32_t app_code_barker;
  85. uint32_t app_code_csf;
  86. uint32_t dcd_ptr_ptr;
  87. uint32_t super_root_key;
  88. uint32_t dcd_ptr;
  89. uint32_t app_dest_ptr;
  90. } flash_header_v1_t;
  91. typedef struct {
  92. uint32_t length; /* Length of data to be read from flash */
  93. } flash_cfg_parms_t;
  94. typedef struct {
  95. flash_header_v1_t fhdr;
  96. dcd_v1_t dcd_table;
  97. flash_cfg_parms_t ext_header;
  98. } imx_header_v1_t;
  99. typedef struct {
  100. uint32_t addr;
  101. uint32_t value;
  102. } dcd_addr_data_t;
  103. typedef struct {
  104. uint8_t tag;
  105. uint16_t length;
  106. uint8_t version;
  107. } __attribute__((packed)) ivt_header_t;
  108. typedef struct {
  109. uint8_t tag;
  110. uint16_t length;
  111. uint8_t param;
  112. } __attribute__((packed)) write_dcd_command_t;
  113. typedef struct {
  114. ivt_header_t header;
  115. write_dcd_command_t write_dcd_command;
  116. dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2];
  117. } dcd_v2_t;
  118. typedef struct {
  119. uint32_t start;
  120. uint32_t size;
  121. uint32_t plugin;
  122. } boot_data_t;
  123. typedef struct {
  124. ivt_header_t header;
  125. uint32_t entry;
  126. uint32_t reserved1;
  127. uint32_t dcd_ptr;
  128. uint32_t boot_data_ptr;
  129. uint32_t self;
  130. uint32_t csf;
  131. uint32_t reserved2;
  132. } flash_header_v2_t;
  133. typedef struct {
  134. flash_header_v2_t fhdr;
  135. boot_data_t boot_data;
  136. dcd_v2_t dcd_table;
  137. } imx_header_v2_t;
  138. /* The header must be aligned to 4k on MX53 for NAND boot */
  139. struct imx_header {
  140. union {
  141. imx_header_v1_t hdr_v1;
  142. imx_header_v2_t hdr_v2;
  143. } header;
  144. uint32_t flash_offset;
  145. } __attribute__((aligned(4096)));
  146. typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
  147. char *name, int lineno,
  148. int fld, uint32_t value,
  149. uint32_t off);
  150. typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr,
  151. uint32_t dcd_len,
  152. char *name, int lineno);
  153. typedef void (*set_imx_hdr_t)(struct imx_header *imxhdr, uint32_t dcd_len,
  154. uint32_t entry_point, uint32_t flash_offset);
  155. #endif /* _IMXIMAGE_H_ */