spiflash_toc.h (5222B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 6 * 7 * Arm Processor Subsystem flash utility 8 */ 9 10 /* 11 * Warning: 12 * This file is included by both uKernel and host code. Be very careful 13 * about what goes into this file, esp. with regards to including other 14 * files. 15 */ 16 17 #ifndef SPIFLASH_TOC_H 18 #define SPIFLASH_TOC_H 19 20 #ifdef BCM_UKERNEL 21 #include "sdk_typedefs.h" 22 #else 23 #include <sal/types.h> 24 #endif 25 26 #include <soc/shared/mos_coredump.h> 27 28 /* 29 * Flash header at the beginning of flash that tells the ROM where 30 * to find images and switch configuration info. 31 */ 32 33 #define FLASH_NUM_HEADER_BLOCKS 2 34 #define FLASH_HEADER_MAGIC 0xa5c35a3c 35 #define FLASH_HEADER_MAGIC2 0xb6d46b4d 36 #define FLASH_NUM_BOOT_IMAGES 2 37 #define FLASH_NUM_IMAGES 4 38 #define FLASH_NUM_CONFIGS 2 39 #define FLASH_NUM_AVB_CONFIGS 2 40 #define FLASH_NUM_CORE_DUMPS 1 41 #define FLASH_NUM_EXPANSION_BLOCKS 4 42 43 #define FLASH_ARM_IMAGE_SIZE ((128 + 64) * 1024) /* 128K itcm, 64K dtcm */ 44 #define FLASH_SWITCH_IMAGE_SIZE (8 * 1024) /* Maximum switch configuration size */ 45 #define FLASH_AVB_IMAGE_SIZE (8 * 1024) /* Maximum AVB configuration size */ 46 #define FLASH_CORE_IMAGE_SIZE ((128 + 64) * 1024) 47 #define FLASH_AVB_CONFIG_SIZE (16 * 1024) 48 #define FLASH_VPD_SIZE 256 49 #define AVB_CFG_EXP_OFFSET 0 50 #define VPD_EXP_OFFSET 2 51 52 typedef struct flash_expansion_s { 53 uint32 offset; 54 uint32 length; 55 } flash_expansion_t; 56 57 typedef struct flash_header_s { 58 uint32 magic; /* magic number */ 59 uint32 cksum; /* simple checksum */ 60 uint32 spi_speed; /* new SPI speed */ 61 uint32 dmu_config; /* DMU clock config to use */ 62 uint32 boot_image[FLASH_NUM_BOOT_IMAGES]; /* boot image numbers */ 63 uint32 image_offset[FLASH_NUM_IMAGES]; /* images */ 64 uint32 config_offset[FLASH_NUM_CONFIGS]; /* switch configs */ 65 uint32 core_dump_offset[FLASH_NUM_CORE_DUMPS]; /* offset for the core dump */ 66 flash_expansion_t expansion[FLASH_NUM_EXPANSION_BLOCKS]; 67 68 /* For future expansion */ 69 uint32 unused[16 - 2 * FLASH_NUM_EXPANSION_BLOCKS]; 70 71 /* For Polar B0/ARM_CLK_CONFIG - DMU configuration values */ 72 uint32 magic2; /* magic number */ 73 uint32 cksum2; /* checksum */ 74 uint32 dmu_hclk_freq; 75 uint32 dmu_hclk_sel; 76 uint32 dmu_pclk_freq; 77 uint32 dmu_pclk_sel; 78 uint32 dmu_p1div; 79 uint32 dmu_p2div; 80 uint32 dmu_ndiv; 81 uint32 dmu_m1div; 82 uint32 dmu_m2div; 83 uint32 dmu_m3div; 84 uint32 dmu_m4div; 85 uint32 dmu_pll_num; 86 uint32 dmu_frac; 87 uint32 dmu_bclk_sel; 88 } flash_header_t; 89 90 /* 91 * Image header at the start of each ARM image. 92 */ 93 94 #define IMAGE_HEADER_MAGIC 0x7865cbe3 95 96 typedef struct mos_arm_image_header_s { 97 uint32 magic; /* magic number */ 98 uint32 cksum; /* header checksum */ 99 uint32 image_cksum; /* image checksum */ 100 uint32 length; /* image length in bytes */ 101 } mos_arm_image_header_t; 102 103 /* 104 * Switch configuration header 105 */ 106 #define SWITCH_IMAGE_HEADER_MAGIC_ROM 0xe523fc72 107 #define SWITCH_IMAGE_HEADER_MAGIC_PROD 0xe523fc71 108 109 typedef struct mos_switch_config_header_s { 110 uint32 magic; /* magic number */ 111 uint32 cksum; /* header checksum */ 112 uint32 image_cksum; /* image checksum */ 113 uint32 length; /* image length in bytes */ 114 } mos_switch_config_header_t; 115 116 /* 117 * Switch configuration entry 118 */ 119 120 typedef struct mos_switch_config_entry_s { 121 uint32 address; 122 uint32 size; 123 uint64 value; 124 } mos_switch_config_entry_t; 125 126 /* 127 * Core dump image header 128 */ 129 #define MOS_COREDUMP_HEADER_MAGIC 0x65fc2d9a 130 #define MOS_COREDUMP_REGIONS 6 /* max number of memory regions */ 131 132 typedef struct mos_coredump_header_s { 133 uint32 magic; /* magic number */ 134 uint32 start; /* first page of data */ 135 uint32 end; /* last page of data + 1 */ 136 mos_coredump_region_t regions[MOS_COREDUMP_REGIONS + 1]; 137 } mos_coredump_header_t; 138 139 /* 140 * General expansion header 141 */ 142 typedef struct mos_flash_expansion_header_s { 143 uint32 magic; /* magic number*/ 144 uint32 cksum; /* header checksum */ 145 uint32 image_cksum; /* image checksum in bytes*/ 146 uint32 length; /* image length in bytes*/ 147 } mos_flash_expansion_header_t; 148 149 /* 150 * AVB configuration header 151 */ 152 153 #define AVB_CONFIG_HEADER_MAGIC 0xe523fc72 154 #endif