1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef __CFIFLASH_INTERNAL_H__ 16 #define __CFIFLASH_INTERNAL_H__ 17 18 #include "cfiflash.h" 19 20 #define CFIFLASH_ONE_BANK_BITS 24 21 22 #define CFIFLASH_SEC_SIZE 512 23 #define CFIFLASH_SEC_SIZE_BITS 9 24 #define CFIFLASH_SECTORS (CFIFLASH_CAPACITY / CFIFLASH_SEC_SIZE) 25 26 #define CFIFLASH_PAGE_SIZE (2048 * 2) /* fit QEMU of 2 banks */ 27 #define CFIFLASH_PAGE_WORDS (CFIFLASH_PAGE_SIZE / sizeof(uint32_t)) 28 #define CFIFLASH_PAGE_WORDS_MASK (CFIFLASH_PAGE_WORDS - 1) 29 30 #define CFIFLASH_QUERY_CMD 0x98 31 #define CFIFLASH_QUERY_BASE 0x55 32 #define CFIFLASH_QUERY_QRY 0x10 33 #define CFIFLASH_QUERY_VENDOR 0x13 34 #define CFIFLASH_QUERY_SIZE 0x27 35 #define CFIFLASH_QUERY_PAGE_BITS 0x2A 36 #define CFIFLASH_QUERY_ERASE_REGION 0x2C 37 #define CFIFLASH_QUERY_BLOCKS 0x2D 38 #define CFIFLASH_QUERY_BLOCK_SIZE 0x2F 39 #define CFIFLASH_EXPECT_VENDOR 1 /* Intel command set */ 40 #define CFIFLASH_EXPECT_PAGE_BITS 11 41 #define CFIFLASH_EXPECT_BLOCKS 127 /* plus 1: # of blocks, arm_virt is 255, riscv32 is 127 */ 42 #define CFIFLASH_EXPECT_BLOCK_SIZE 512 /* times 128: block size */ 43 #define CFIFLASH_EXPECT_ERASE_REGION 1 44 45 #define CFIFLASH_CMD_ERASE 0x20 46 #define CFIFLASH_CMD_CLEAR_STATUS 0x50 47 #define CFIFLASH_CMD_READ_STATUS 0x70 48 #define CFIFLASH_CMD_CONFIRM 0xD0 49 #define CFIFLASH_CMD_BUFWRITE 0xE8 50 #define CFIFLASH_CMD_RESET 0xFF 51 52 #define CFIFLASH_STATUS_READY_MASK 0x80 53 54 #endif /* __CFIFLASH_INTERNAL_H__ */ 55