1d6aed566Sopenharmony_ci/* 2d6aed566Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3d6aed566Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d6aed566Sopenharmony_ci * you may not use this file except in compliance with the License. 5d6aed566Sopenharmony_ci * You may obtain a copy of the License at 6d6aed566Sopenharmony_ci * 7d6aed566Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d6aed566Sopenharmony_ci * 9d6aed566Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d6aed566Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d6aed566Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d6aed566Sopenharmony_ci * See the License for the specific language governing permissions and 13d6aed566Sopenharmony_ci * limitations under the License. 14d6aed566Sopenharmony_ci */ 15d6aed566Sopenharmony_ci#ifndef __CFIFLASH_H__ 16d6aed566Sopenharmony_ci#define __CFIFLASH_H__ 17d6aed566Sopenharmony_ci 18d6aed566Sopenharmony_ci#include "stdint.h" 19d6aed566Sopenharmony_ci 20d6aed566Sopenharmony_ci#define CFIFLASH_MAX_NUM 2 21d6aed566Sopenharmony_ci#define CFIFLASH_CAPACITY (32 * 1024 * 1024) 22d6aed566Sopenharmony_ci#define CFIFLASH_ERASEBLK_SIZE (128 * 1024 * 2) /* fit QEMU of 2 banks */ 23d6aed566Sopenharmony_ci#define CFIFLASH_ERASEBLK_WORDS (CFIFLASH_ERASEBLK_SIZE / sizeof(uint32_t)) 24d6aed566Sopenharmony_ci#define CFIFLASH_ERASEBLK_WORDMASK (~(CFIFLASH_ERASEBLK_WORDS - 1)) 25d6aed566Sopenharmony_ci 26d6aed566Sopenharmony_ci/* Results of Flash Functions */ 27d6aed566Sopenharmony_citypedef enum { 28d6aed566Sopenharmony_ci FLASH_OK = 0, /* 0: Successful */ 29d6aed566Sopenharmony_ci FLASH_ERROR /* 1: R/W Error */ 30d6aed566Sopenharmony_ci} FLASH_DRESULT; 31d6aed566Sopenharmony_ci 32d6aed566Sopenharmony_ciunsigned CfiFlashSec2Bytes(unsigned sector); 33d6aed566Sopenharmony_ci 34d6aed566Sopenharmony_ciint CfiFlashQuery(uint32_t pdrv); 35d6aed566Sopenharmony_ciint32_t CfiFlashRead(uint32_t pdrv, uint32_t *buffer, uint32_t offset, uint32_t nbytes); 36d6aed566Sopenharmony_ciint32_t CfiFlashWrite(uint32_t pdrv, const uint32_t *buffer, uint32_t offset, uint32_t nbytes); 37d6aed566Sopenharmony_ciint32_t CfiFlashErase(uint32_t pdrv, uint32_t offset); 38d6aed566Sopenharmony_ci 39d6aed566Sopenharmony_ci#if (LOSCFG_SUPPORT_FATFS == 1) 40d6aed566Sopenharmony_ci#include "fatfs.h" 41d6aed566Sopenharmony_ci#include "ff_gen_drv.h" 42d6aed566Sopenharmony_ci 43d6aed566Sopenharmony_ciDiskioDrvTypeDef *GetCfiBlkOps(void); 44d6aed566Sopenharmony_ci#endif /* LOSCFG_SUPPORT_FATFS == 1 */ 45d6aed566Sopenharmony_ci 46d6aed566Sopenharmony_ci#if (LOSCFG_SUPPORT_LITTLEFS == 1) 47d6aed566Sopenharmony_ci#include "lfs.h" 48d6aed566Sopenharmony_ci 49d6aed566Sopenharmony_ciint LittlefsDriverInit(void); 50d6aed566Sopenharmony_cistruct lfs_config* GetCfiLfsCfg(void); 51d6aed566Sopenharmony_ci#endif /* LOSCFG_SUPPORT_LITTLEFS == 1 */ 52d6aed566Sopenharmony_ci 53d6aed566Sopenharmony_ci#endif /* __CFIFLASH_H__ */ 54