1 /* Copyright 2014 The Chromium OS Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6 #ifndef __CROS_EC_FLASH_LAYOUT_H 7 #define __CROS_EC_FLASH_LAYOUT_H 8 9 /* 10 * The flash memory is implemented in two halves. The SoC bootrom will look for 11 * a first-stage bootloader (aka "RO firmware") at the beginning of each of the 12 * two halves and prefer the newer one if both are valid. The chosen bootloader 13 * also looks in each half of the flash for a valid application image (("RW 14 * firmware"), so we have two possible RW images as well. The RO and RW images 15 * are not tightly coupled, so either RO image can choose to boot either RW 16 * image. RO images are provided by the SoC team, and can be updated separately 17 * from the RW images. 18 */ 19 20 /* Flash is directly addressable */ 21 #if defined(CHIP_H1D1) 22 #define CHIP_FLASH_BASE 0x80000 23 #define CHIP_FLASH_SIZE (1024 * 1024) 24 #else 25 #define CHIP_FLASH_BASE 0x40000 26 #define CHIP_FLASH_SIZE (512 * 1024) 27 #endif 28 #define CHIP_FLASH_HALF (CHIP_FLASH_SIZE >> 1) 29 30 /* Each half has to leave room for the image's signed header */ 31 #define CHIP_SIG_HEADER_SIZE 1024 32 33 /* This isn't optional, since the bootrom will always look for both */ 34 #define CHIP_HAS_RO_B 35 36 /* The RO images start at the very beginning of each flash half */ 37 #define CHIP_RO_A_MEM_OFF 0 38 #define CHIP_RO_B_MEM_OFF CHIP_FLASH_HALF 39 40 /* Size reserved for each RO image */ 41 #define CHIP_RO_SIZE 0x4000 42 43 /* 44 * RW images start right after the reserved-for-RO areas in each half, but only 45 * because that's where the RO images look for them. It's not a HW constraint. 46 */ 47 #define CHIP_RW_A_MEM_OFF CHIP_RO_SIZE 48 #define CHIP_RW_B_MEM_OFF (CHIP_FLASH_HALF + CHIP_RW_A_MEM_OFF) 49 50 /* 51 * Any reserved flash storage is placed after the RW image. It makes A/B 52 * updates MUCH simpler if both RW images are the same size, so we reserve the 53 * same amount in each half. 54 */ 55 #define CHIP_RW_SIZE \ 56 (CHIP_FLASH_HALF - CHIP_RW_A_MEM_OFF - CONFIG_FLASH_TOP_SIZE) 57 58 /* Reserved flash offset starts here. */ 59 #define CHIP_FLASH_TOP_A_OFF (CHIP_FLASH_HALF - CONFIG_FLASH_TOP_SIZE) 60 #define CHIP_FLASH_TOP_B_OFF (CHIP_FLASH_SIZE - CONFIG_FLASH_TOP_SIZE) 61 62 63 /* Internal flash specifics */ 64 #define CHIP_FLASH_BANK_SIZE 0x800 /* protect bank size */ 65 #define CHIP_FLASH_ERASE_SIZE 0x800 /* erase bank size */ 66 67 /* This flash can only be written as 4-byte words (aligned properly, too). */ 68 #define CHIP_FLASH_ERASED_VALUE32 0xffffffff 69 #define CHIP_FLASH_WRITE_SIZE 4 /* min write size (bytes) */ 70 71 /* But we have a 32-word buffer for writing multiple adjacent cells */ 72 #define CHIP_FLASH_WRITE_IDEAL_SIZE 128 /* best write size (bytes) */ 73 74 /* The flash controller prevents bulk writes that cross row boundaries */ 75 #define CHIP_FLASH_ROW_SIZE 256 /* row size */ 76 77 /* Manufacturing related data. */ 78 /* Certs in the RO region are written as 4-kB + 3-kB blocks to the A & 79 * B banks respectively. 80 */ 81 #define RO_CERTS_A_OFF (CHIP_RO_A_MEM_OFF + 0x2800) 82 #define RO_CERTS_B_OFF (CHIP_RO_B_MEM_OFF + 0x2800) 83 #define RO_CERTS_A_SIZE 0x01000 84 #define RO_CERTS_B_SIZE 0x00c00 85 /* 86 * Flash erases must be multiples of CHIP_FLASH_ERASE_SIZE, so in 87 * order to rewrite CERTS_B, we need wipe RO_CERTS_ERASE_SIZE rather 88 * than CERTS_B_SIZE. 89 */ 90 #define RO_CERTS_ERASE_SIZE 0x01000 91 /* We have an unused 3-kB region in the B bank, for future proofing. */ 92 #define RO_CERTS_PAD_B_SIZE 0x00c00 93 /* Factory provision data is written as a 2-kB block to the A bank. */ 94 #define RO_PROVISION_DATA_A_OFF 0x3800 95 #define RO_PROVISION_DATA_A_SIZE 0x0800 96 97 #endif /* __CROS_EC_FLASH_LAYOUT_H */ 98