CARPLAY版本整理
This commit is contained in:
178
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud.h
Normal file
178
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud.h
Normal file
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* This file is part of the Serial Flash Universal Driver Library.
|
||||
*
|
||||
* Copyright (c) 2016-2018, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* 'Software'), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Function: It is an head file for this library. You can see all of the functions which can be called by user.
|
||||
* Created on: 2016-04-23
|
||||
*/
|
||||
|
||||
#ifndef _SFUD_H_
|
||||
#define _SFUD_H_
|
||||
|
||||
#include "sfud_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ../src/sfup.c */
|
||||
/**
|
||||
* SFUD library initialize.
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_init(void);
|
||||
|
||||
/**
|
||||
* SFUD initialize by flash device
|
||||
*
|
||||
* @param flash flash device
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_device_init(sfud_flash *flash);
|
||||
|
||||
/**
|
||||
* get flash device by its index which in the flash information table
|
||||
*
|
||||
* @param index the index which in the flash information table @see flash_table
|
||||
*
|
||||
* @return flash device
|
||||
*/
|
||||
sfud_flash *sfud_get_device(size_t index);
|
||||
|
||||
/**
|
||||
* get flash device total number on flash device information table @see flash_table
|
||||
*
|
||||
* @return flash device total number
|
||||
*/
|
||||
size_t sfud_get_device_num(void);
|
||||
|
||||
/**
|
||||
* get flash device information table @see flash_table
|
||||
*
|
||||
* @return flash device table pointer
|
||||
*/
|
||||
const sfud_flash *sfud_get_device_table(void);
|
||||
|
||||
#ifdef SFUD_USING_QSPI
|
||||
/**
|
||||
* Enbale the fast read mode in QSPI flash mode. Default read mode is normal SPI mode.
|
||||
*
|
||||
* it will find the appropriate fast-read instruction to replace the read instruction(0x03)
|
||||
* fast-read instruction @see SFUD_FLASH_EXT_INFO_TABLE
|
||||
*
|
||||
* @note When Flash is in QSPI mode, the method must be called after sfud_device_init().
|
||||
*
|
||||
* @param flash flash device
|
||||
* @param data_line_width the data lines max width which QSPI bus supported, such as 1, 2, 4
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_qspi_fast_read_enable(sfud_flash *flash, uint8_t data_line_width);
|
||||
#endif /* SFUD_USING_QSPI */
|
||||
|
||||
/**
|
||||
* read flash data
|
||||
*
|
||||
* @param flash flash device
|
||||
* @param addr start address
|
||||
* @param size read size
|
||||
* @param data read data pointer
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_read(const sfud_flash *flash, uint32_t addr, size_t size, uint8_t *data);
|
||||
|
||||
/**
|
||||
* erase flash data
|
||||
*
|
||||
* @note It will erase align by erase granularity.
|
||||
*
|
||||
* @param flash flash device
|
||||
* @param addr start address
|
||||
* @param size erase size
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_erase(const sfud_flash *flash, uint32_t addr, size_t size);
|
||||
|
||||
/**
|
||||
* write flash data (no erase operate)
|
||||
*
|
||||
* @param flash flash device
|
||||
* @param addr start address
|
||||
* @param data write data
|
||||
* @param size write size
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_write(const sfud_flash *flash, uint32_t addr, size_t size, const uint8_t *data);
|
||||
|
||||
/**
|
||||
* erase and write flash data
|
||||
*
|
||||
* @param flash flash device
|
||||
* @param addr start address
|
||||
* @param size write size
|
||||
* @param data write data
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_erase_write(const sfud_flash *flash, uint32_t addr, size_t size, const uint8_t *data);
|
||||
|
||||
/**
|
||||
* erase all flash data
|
||||
*
|
||||
* @param flash flash device
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_chip_erase(const sfud_flash *flash);
|
||||
|
||||
/**
|
||||
* read flash register status
|
||||
*
|
||||
* @param flash flash device
|
||||
* @param status register status
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_read_status(const sfud_flash *flash, uint8_t *status, uint8_t cmd);
|
||||
|
||||
/**
|
||||
* write status register
|
||||
*
|
||||
* @param flash flash device
|
||||
* @param is_volatile true: volatile mode, false: non-volatile mode
|
||||
* @param status register status
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
sfud_err sfud_write_status(const sfud_flash *flash, bool is_volatile, uint8_t status, uint8_t cmd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SFUD_H_ */
|
54
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud_cfg.h
Normal file
54
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud_cfg.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of the Serial Flash Universal Driver Library.
|
||||
*
|
||||
* Copyright (c) 2016-2018, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* 'Software'), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Function: It is the configure head file for this library.
|
||||
* Created on: 2016-04-23
|
||||
*/
|
||||
|
||||
#ifndef _SFUD_CFG_H_
|
||||
#define _SFUD_CFG_H_
|
||||
|
||||
#include "board.h"
|
||||
|
||||
//#define SFUD_DEBUG_MODE
|
||||
#ifdef SPI0_QSPI_MODE
|
||||
#define SFUD_USING_QSPI
|
||||
#endif
|
||||
|
||||
#define SFUD_USING_SFDP
|
||||
|
||||
#define SFUD_USING_FLASH_INFO_TABLE
|
||||
|
||||
enum {
|
||||
SFUD_W25Q128_DEVICE_INDEX = 0,
|
||||
};
|
||||
|
||||
#define SFUD_FLASH_DEVICE_TABLE \
|
||||
{ \
|
||||
[SFUD_W25Q128_DEVICE_INDEX] = {.name = "W25Q128", .spi.name = "spi0"}, \
|
||||
}
|
||||
|
||||
//#define SFUD_USING_QSPI
|
||||
|
||||
#endif /* _SFUD_CFG_H_ */
|
320
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud_def.h
Normal file
320
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud_def.h
Normal file
@ -0,0 +1,320 @@
|
||||
/*
|
||||
* This file is part of the Serial Flash Universal Driver Library.
|
||||
*
|
||||
* Copyright (c) 2016-2018, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* 'Software'), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Function: It is the macro definition head file for this library.
|
||||
* Created on: 2016-04-23
|
||||
*/
|
||||
|
||||
#ifndef _SFUD_DEF_H_
|
||||
#define _SFUD_DEF_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <sfud_cfg.h>
|
||||
#include "sfud_flash_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* debug print function. Must be implement by user. */
|
||||
#ifdef SFUD_DEBUG_MODE
|
||||
#ifndef SFUD_DEBUG
|
||||
#define SFUD_DEBUG(...) sfud_log_debug(__FILE__, __LINE__, __VA_ARGS__)
|
||||
#endif /* SFUD_DEBUG */
|
||||
#else
|
||||
#define SFUD_DEBUG(...)
|
||||
#endif /* SFUD_DEBUG_MODE */
|
||||
|
||||
#ifndef SFUD_INFO
|
||||
#define SFUD_INFO(...) sfud_log_info(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/* assert for developer. */
|
||||
#ifdef SFUD_DEBUG_MODE
|
||||
#define SFUD_ASSERT(EXPR) \
|
||||
if (!(EXPR)) \
|
||||
{ \
|
||||
SFUD_DEBUG("(%s) has assert failed at %s.", #EXPR, __FUNCTION__); \
|
||||
while (1); \
|
||||
}
|
||||
#else
|
||||
#define SFUD_ASSERT(EXPR)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* retry process
|
||||
*
|
||||
* @param delay delay function for every retry. NULL will not delay for every retry.
|
||||
* @param retry retry counts
|
||||
* @param result SFUD_ERR_TIMEOUT: retry timeout
|
||||
*/
|
||||
#define SFUD_RETRY_PROCESS(delay, retry, result) \
|
||||
void (*__delay_temp)(void) = (void (*)(void))delay; \
|
||||
if (retry == 0) {result = SFUD_ERR_TIMEOUT;break;} \
|
||||
else {if (__delay_temp) {__delay_temp();} retry --;}
|
||||
|
||||
/* software version number */
|
||||
#define SFUD_SW_VERSION "1.1.0"
|
||||
/*
|
||||
* all defined supported command
|
||||
*/
|
||||
#ifndef SFUD_CMD_WRITE_ENABLE
|
||||
#define SFUD_CMD_WRITE_ENABLE 0x06
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_WRITE_DISABLE
|
||||
#define SFUD_CMD_WRITE_DISABLE 0x04
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_READ_STATUS_REGISTER
|
||||
#define SFUD_CMD_READ_STATUS_REGISTER 0x05
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_READ_STATUS_REGISTER2
|
||||
#define SFUD_CMD_READ_STATUS_REGISTER2 0x35
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_READ_STATUS_REGISTER3
|
||||
#define SFUD_CMD_READ_STATUS_REGISTER3 0x15
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_VOLATILE_SR_WRITE_ENABLE
|
||||
#define SFUD_VOLATILE_SR_WRITE_ENABLE 0x50
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_WRITE_STATUS_REGISTER
|
||||
#define SFUD_CMD_WRITE_STATUS_REGISTER 0x01
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_WRITE_STATUS_REGISTER2
|
||||
#define SFUD_CMD_WRITE_STATUS_REGISTER2 0x31
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_WRITE_STATUS_REGISTER3
|
||||
#define SFUD_CMD_WRITE_STATUS_REGISTER3 0x11
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_PAGE_PROGRAM
|
||||
#define SFUD_CMD_PAGE_PROGRAM 0x02
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_AAI_WORD_PROGRAM
|
||||
#define SFUD_CMD_AAI_WORD_PROGRAM 0xAD
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_ERASE_CHIP
|
||||
#define SFUD_CMD_ERASE_CHIP 0xC7
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_READ_DATA
|
||||
#define SFUD_CMD_READ_DATA 0x03
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_DUAL_OUTPUT_READ_DATA
|
||||
#define SFUD_CMD_DUAL_OUTPUT_READ_DATA 0x3B
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_DUAL_IO_READ_DATA
|
||||
#define SFUD_CMD_DUAL_IO_READ_DATA 0xBB
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_QUAD_IO_READ_DATA
|
||||
#define SFUD_CMD_QUAD_IO_READ_DATA 0xEB
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_QUAD_OUTPUT_READ_DATA
|
||||
#define SFUD_CMD_QUAD_OUTPUT_READ_DATA 0x6B
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_MANUFACTURER_DEVICE_ID
|
||||
#define SFUD_CMD_MANUFACTURER_DEVICE_ID 0x90
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_JEDEC_ID
|
||||
#define SFUD_CMD_JEDEC_ID 0x9F
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_READ_UNIQUE_ID
|
||||
#define SFUD_CMD_READ_UNIQUE_ID 0x4B
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_READ_SFDP_REGISTER
|
||||
#define SFUD_CMD_READ_SFDP_REGISTER 0x5A
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_ENABLE_RESET
|
||||
#define SFUD_CMD_ENABLE_RESET 0x66
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_RESET
|
||||
#define SFUD_CMD_RESET 0x99
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_ENTER_4B_ADDRESS_MODE
|
||||
#define SFUD_CMD_ENTER_4B_ADDRESS_MODE 0xB7
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_CMD_EXIT_4B_ADDRESS_MODE
|
||||
#define SFUD_CMD_EXIT_4B_ADDRESS_MODE 0xE9
|
||||
#endif
|
||||
|
||||
#ifndef SFUD_WRITE_MAX_PAGE_SIZE
|
||||
#define SFUD_WRITE_MAX_PAGE_SIZE 256
|
||||
#endif
|
||||
|
||||
/* send dummy data for read data */
|
||||
#ifndef SFUD_DUMMY_DATA
|
||||
#define SFUD_DUMMY_DATA 0xFF
|
||||
#endif
|
||||
|
||||
/* maximum number of erase type support on JESD216 (V1.0) */
|
||||
#define SFUD_SFDP_ERASE_TYPE_MAX_NUM 4
|
||||
|
||||
/**
|
||||
* status register bits
|
||||
*/
|
||||
enum {
|
||||
SFUD_STATUS_REGISTER_BUSY = (1 << 0), /**< busing */
|
||||
SFUD_STATUS_REGISTER_WEL = (1 << 1), /**< write enable latch */
|
||||
SFUD_STATUS_REGISTER_SRP = (1 << 7), /**< status register protect */
|
||||
};
|
||||
|
||||
/**
|
||||
* error code
|
||||
*/
|
||||
typedef enum {
|
||||
SFUD_SUCCESS = 0, /**< success */
|
||||
SFUD_ERR_NOT_FOUND = 1, /**< not found or not supported */
|
||||
SFUD_ERR_WRITE = 2, /**< write error */
|
||||
SFUD_ERR_READ = 3, /**< read error */
|
||||
SFUD_ERR_TIMEOUT = 4, /**< timeout error */
|
||||
SFUD_ERR_ADDR_OUT_OF_BOUND = 5, /**< address is out of flash bound */
|
||||
|
||||
//add for spi nand flash.
|
||||
SFUD_ERR_ERASE,
|
||||
SFUD_ERR_READ_ECC,
|
||||
SFUD_ERR_BAD_BLK,
|
||||
} sfud_err;
|
||||
|
||||
#ifdef SFUD_USING_QSPI
|
||||
/**
|
||||
* QSPI flash read cmd format
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t instruction;
|
||||
uint8_t instruction_lines;
|
||||
uint8_t address_size;
|
||||
uint8_t address_lines;
|
||||
uint8_t alternate_bytes_lines;
|
||||
uint8_t dummy_cycles;
|
||||
uint8_t data_lines;
|
||||
} sfud_qspi_read_cmd_format;
|
||||
#endif /* SFUD_USING_QSPI */
|
||||
|
||||
/* SPI bus write read data function type */
|
||||
typedef sfud_err (*spi_write_read_func)(const uint8_t *write_buf, size_t write_size, uint8_t *read_buf, size_t read_size);
|
||||
|
||||
#ifdef SFUD_USING_SFDP
|
||||
/**
|
||||
* the SFDP (Serial Flash Discoverable Parameters) parameter info which used on this library
|
||||
*/
|
||||
typedef struct {
|
||||
bool available; /**< available when read SFDP OK */
|
||||
uint8_t major_rev; /**< SFDP Major Revision */
|
||||
uint8_t minor_rev; /**< SFDP Minor Revision */
|
||||
uint16_t write_gran; /**< write granularity (bytes) */
|
||||
uint8_t erase_4k; /**< 4 kilobyte erase is supported throughout the device */
|
||||
uint8_t erase_4k_cmd; /**< 4 Kilobyte erase command */
|
||||
bool sr_is_non_vola; /**< status register is supports non-volatile */
|
||||
uint8_t vola_sr_we_cmd; /**< volatile status register write enable command */
|
||||
bool addr_3_byte; /**< supports 3-Byte addressing */
|
||||
bool addr_4_byte; /**< supports 4-Byte addressing */
|
||||
uint32_t capacity; /**< flash capacity (bytes) */
|
||||
struct {
|
||||
uint32_t size; /**< erase sector size (bytes). 0x00: not available */
|
||||
uint8_t cmd; /**< erase command */
|
||||
} eraser[SFUD_SFDP_ERASE_TYPE_MAX_NUM]; /**< supported eraser types table */
|
||||
//TODO lots of fast read-related stuff (like modes supported and number of wait states/dummy cycles needed in each)
|
||||
} sfud_sfdp, *sfud_sfdp_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SPI device
|
||||
*/
|
||||
struct __sfud_flash;
|
||||
typedef struct __sfud_spi {
|
||||
/* SPI device name */
|
||||
char *name;
|
||||
/* SPI bus write read data function */
|
||||
sfud_err (*wr)(const struct __sfud_spi *spi, const uint8_t *write_buf, size_t write_size, uint8_t *read_buf,
|
||||
size_t read_size);
|
||||
#ifdef SFUD_USING_QSPI
|
||||
/* QSPI fast read function */
|
||||
sfud_err (*qspi_read)(const struct __sfud_spi *spi, uint32_t addr, sfud_qspi_read_cmd_format *qspi_read_cmd_format,
|
||||
uint8_t *read_buf, size_t read_size);
|
||||
#endif
|
||||
/* lock SPI bus */
|
||||
void (*lock)(const struct __sfud_spi *spi);
|
||||
/* unlock SPI bus */
|
||||
void (*unlock)(const struct __sfud_spi *spi);
|
||||
/* flash device */
|
||||
struct __sfud_flash *flash;
|
||||
/* some user data */
|
||||
void *user_data;
|
||||
} sfud_spi, *sfud_spi_t;
|
||||
|
||||
/**
|
||||
* serial flash device
|
||||
*/
|
||||
typedef struct __sfud_flash {
|
||||
char *name; /**< serial flash name */
|
||||
size_t index; /**< index of flash device information table @see flash_table */
|
||||
sfud_flash_chip chip; /**< flash chip information */
|
||||
sfud_spi spi; /**< SPI device */
|
||||
bool init_ok; /**< initialize OK flag */
|
||||
bool addr_in_4_byte; /**< flash is in 4-Byte addressing */
|
||||
struct {
|
||||
void (*delay)(void); /**< every retry's delay */
|
||||
size_t times; /**< default times for error retry */
|
||||
} retry;
|
||||
void *user_data; /**< some user data */
|
||||
|
||||
#ifdef SFUD_USING_QSPI
|
||||
sfud_qspi_read_cmd_format read_cmd_format; /**< fast read cmd format */
|
||||
#endif
|
||||
|
||||
#ifdef SFUD_USING_SFDP
|
||||
sfud_sfdp sfdp; /**< serial flash discoverable parameters by JEDEC standard */
|
||||
#endif
|
||||
|
||||
} sfud_flash, *sfud_flash_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SFUD_DEF_H_ */
|
201
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud_flash_def.h
Normal file
201
MXC_A27-PCB4.5-270T/lib/sfud/inc/sfud_flash_def.h
Normal file
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* This file is part of the Serial Flash Universal Driver Library.
|
||||
*
|
||||
* Copyright (c) 2016-2018, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* 'Software'), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Function: It is the flash types and specification macro definition head file for this library.
|
||||
* Created on: 2016-06-09
|
||||
*/
|
||||
|
||||
#ifndef _SFUD_FLASH_DEF_H_
|
||||
#define _SFUD_FLASH_DEF_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sfud_cfg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* flash program(write) data mode
|
||||
*/
|
||||
enum sfud_write_mode {
|
||||
SFUD_WM_PAGE_256B = 1 << 0, /**< write 1 to 256 bytes per page */
|
||||
SFUD_WM_BYTE = 1 << 1, /**< byte write */
|
||||
SFUD_WM_AAI = 1 << 2, /**< auto address increment */
|
||||
SFUD_WM_DUAL_BUFFER = 1 << 3, /**< dual-buffer write, like AT45DB series */
|
||||
};
|
||||
|
||||
/* manufacturer information */
|
||||
typedef struct {
|
||||
char *name;
|
||||
uint8_t id;
|
||||
} sfud_mf;
|
||||
|
||||
/* flash chip information */
|
||||
typedef struct {
|
||||
char *name; /**< flash chip name */
|
||||
uint8_t mf_id; /**< manufacturer ID */
|
||||
uint8_t type_id; /**< memory type ID */
|
||||
uint8_t capacity_id; /**< capacity ID */
|
||||
uint32_t capacity; /**< flash capacity (bytes) */
|
||||
uint16_t write_mode; /**< write mode @see sfud_write_mode */
|
||||
uint32_t erase_gran; /**< erase granularity (bytes) */
|
||||
uint8_t erase_gran_cmd; /**< erase granularity size block command */
|
||||
} sfud_flash_chip;
|
||||
|
||||
#ifdef SFUD_USING_QSPI
|
||||
/* QSPI flash chip's extended information compared with SPI flash */
|
||||
typedef struct {
|
||||
uint8_t mf_id; /**< manufacturer ID */
|
||||
uint8_t type_id; /**< memory type ID */
|
||||
uint8_t capacity_id; /**< capacity ID */
|
||||
uint8_t read_mode; /**< supported read mode on this qspi flash chip */
|
||||
} sfud_qspi_flash_ext_info;
|
||||
#endif
|
||||
|
||||
/* SFUD support manufacturer JEDEC ID */
|
||||
#define SFUD_MF_ID_CYPRESS 0x01
|
||||
#define SFUD_MF_ID_FUJITSU 0x04
|
||||
#define SFUD_MF_ID_EON 0x1C
|
||||
#define SFUD_MF_ID_ATMEL 0x1F
|
||||
#define SFUD_MF_ID_MICRON 0x20
|
||||
#define SFUD_MF_ID_AMIC 0x37
|
||||
#define SFUD_MF_ID_SANYO 0x62
|
||||
#define SFUD_MF_ID_INTEL 0x89
|
||||
#define SFUD_MF_ID_ESMT 0x8C
|
||||
#define SFUD_MF_ID_FUDAN 0xA1
|
||||
#define SFUD_MF_ID_HYUNDAI 0xAD
|
||||
#define SFUD_MF_ID_SST 0xBF
|
||||
#define SFUD_MF_ID_MICRONIX 0xC2
|
||||
#define SFUD_MF_ID_GIGADEVICE 0xC8
|
||||
#define SFUD_MF_ID_ISSI 0xD5
|
||||
#define SFUD_MF_ID_WINBOND 0xEF
|
||||
|
||||
/* SFUD supported manufacturer information table */
|
||||
#define SFUD_MF_TABLE \
|
||||
{ \
|
||||
{"Cypress", SFUD_MF_ID_CYPRESS}, \
|
||||
{"Fujitsu", SFUD_MF_ID_FUJITSU}, \
|
||||
{"EON", SFUD_MF_ID_EON}, \
|
||||
{"Atmel", SFUD_MF_ID_ATMEL}, \
|
||||
{"Micron", SFUD_MF_ID_MICRON}, \
|
||||
{"AMIC", SFUD_MF_ID_AMIC}, \
|
||||
{"Sanyo", SFUD_MF_ID_SANYO}, \
|
||||
{"Intel", SFUD_MF_ID_INTEL}, \
|
||||
{"ESMT", SFUD_MF_ID_ESMT}, \
|
||||
{"Fudan", SFUD_MF_ID_FUDAN}, \
|
||||
{"Hyundai", SFUD_MF_ID_HYUNDAI}, \
|
||||
{"SST", SFUD_MF_ID_SST}, \
|
||||
{"GigaDevice", SFUD_MF_ID_GIGADEVICE}, \
|
||||
{"ISSI", SFUD_MF_ID_ISSI}, \
|
||||
{"Winbond", SFUD_MF_ID_WINBOND}, \
|
||||
{"Micronix", SFUD_MF_ID_MICRONIX}, \
|
||||
}
|
||||
|
||||
#ifdef SFUD_USING_FLASH_INFO_TABLE
|
||||
/* SFUD supported flash chip information table. If the flash not support JEDEC JESD216 standard,
|
||||
* then the SFUD will find the flash chip information by this table. You can add other flash to here then
|
||||
* notice me for update it. The configuration information name and index reference the sfud_flash_chip structure.
|
||||
* | name | mf_id | type_id | capacity_id | capacity | write_mode | erase_gran | erase_gran_cmd |
|
||||
*/
|
||||
#define SFUD_FLASH_CHIP_TABLE \
|
||||
{ \
|
||||
{"AT45DB161E", SFUD_MF_ID_ATMEL, 0x26, 0x00, 2L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_DUAL_BUFFER, 512, 0x81}, \
|
||||
{"W25Q40BV", SFUD_MF_ID_WINBOND, 0x40, 0x13, 512L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"W25Q16BV", SFUD_MF_ID_WINBOND, 0x40, 0x15, 2L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"W25Q32BV", SFUD_MF_ID_WINBOND, 0x40, 0x16, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"W25Q64CV", SFUD_MF_ID_WINBOND, 0x40, 0x17, 8L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"W25Q64DW", SFUD_MF_ID_WINBOND, 0x60, 0x17, 8L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"W25Q128BV", SFUD_MF_ID_WINBOND, 0x40, 0x18, 16L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"W25Q256FV", SFUD_MF_ID_WINBOND, 0x40, 0x19, 32L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"W25H256JV", SFUD_MF_ID_WINBOND, 0x90, 0x19, 32L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"SST25VF080B", SFUD_MF_ID_SST, 0x25, 0x8E, 1L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
|
||||
{"SST25VF016B", SFUD_MF_ID_SST, 0x25, 0x41, 2L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
|
||||
{"M25P32", SFUD_MF_ID_MICRON, 0x20, 0x16, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 64L*1024L, 0xD8}, \
|
||||
{"M25P80", SFUD_MF_ID_MICRON, 0x20, 0x14, 1L*1024L*1024L, SFUD_WM_PAGE_256B, 64L*1024L, 0xD8}, \
|
||||
{"M25P40", SFUD_MF_ID_MICRON, 0x20, 0x13, 512L*1024L, SFUD_WM_PAGE_256B, 64L*1024L, 0xD8}, \
|
||||
{"EN25Q32B", SFUD_MF_ID_EON, 0x30, 0x16, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"GD25Q64B", SFUD_MF_ID_GIGADEVICE, 0x40, 0x17, 8L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"GD25Q16B", SFUD_MF_ID_GIGADEVICE, 0x40, 0x15, 2L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"GD25Q32C", SFUD_MF_ID_GIGADEVICE, 0x40, 0x16, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"S25FL216K", SFUD_MF_ID_CYPRESS, 0x40, 0x15, 2L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"S25FL032P", SFUD_MF_ID_CYPRESS, 0x02, 0x15, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"A25L080", SFUD_MF_ID_AMIC, 0x30, 0x14, 1L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
{"F25L004", SFUD_MF_ID_ESMT, 0x20, 0x13, 512L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
|
||||
{"PCT25VF016B", SFUD_MF_ID_SST, 0x25, 0x41, 2L*1024L*1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \
|
||||
{"W25H512JV", SFUD_MF_ID_WINBOND, 0x70, 0x20, 64L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}, \
|
||||
}
|
||||
#endif /* SFUD_USING_FLASH_INFO_TABLE */
|
||||
|
||||
#ifdef SFUD_USING_QSPI
|
||||
/* This table saves flash read-fast instructions in QSPI mode,
|
||||
* SFUD can use this table to select the most appropriate read instruction for flash.
|
||||
* | mf_id | type_id | capacity_id | qspi_read_mode |
|
||||
*/
|
||||
#define SFUD_FLASH_EXT_INFO_TABLE \
|
||||
{ \
|
||||
/* W25Q40BV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x40, 0x13, NORMAL_SPI_READ|DUAL_OUTPUT}, \
|
||||
/* W25Q80JV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x40, 0x14, NORMAL_SPI_READ|DUAL_OUTPUT}, \
|
||||
/* W25Q16BV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x40, 0x15, NORMAL_SPI_READ|DUAL_OUTPUT}, \
|
||||
/* W25Q32BV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x40, 0x16, NORMAL_SPI_READ|DUAL_OUTPUT|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* W25Q64JV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x40, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* W25Q128JV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x40, 0x18, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* W25Q256FV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x40, 0x19, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* W25H256JV */ \
|
||||
{SFUD_MF_ID_WINBOND, 0x90, 0x19, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* EN25Q32B */ \
|
||||
{SFUD_MF_ID_EON, 0x30, 0x16, NORMAL_SPI_READ|DUAL_OUTPUT|QUAD_IO}, \
|
||||
/* S25FL216K */ \
|
||||
{SFUD_MF_ID_CYPRESS, 0x40, 0x15, NORMAL_SPI_READ|DUAL_OUTPUT}, \
|
||||
/* A25L080 */ \
|
||||
{SFUD_MF_ID_AMIC, 0x30, 0x14, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO}, \
|
||||
/* A25LQ64 */ \
|
||||
{SFUD_MF_ID_AMIC, 0x40, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_IO}, \
|
||||
/* MX25L3206E and KH25L3206E */ \
|
||||
{SFUD_MF_ID_MICRONIX, 0x20, 0x16, NORMAL_SPI_READ|DUAL_OUTPUT}, \
|
||||
/* GD25Q64B */ \
|
||||
{SFUD_MF_ID_GIGADEVICE, 0x40, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT}, \
|
||||
/* MX25L6433F */ \
|
||||
{SFUD_MF_ID_MICRONIX, 0x20, 0x17, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* MX25L12845G */ \
|
||||
{SFUD_MF_ID_MICRONIX, 0x20, 0x18, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* MX25L25645G */ \
|
||||
{SFUD_MF_ID_MICRONIX, 0x20, 0x19, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
/* GD25B512ME */ \
|
||||
{SFUD_MF_ID_GIGADEVICE, 0x47, 0x1A, NORMAL_SPI_READ|DUAL_OUTPUT|DUAL_IO|QUAD_OUTPUT|QUAD_IO}, \
|
||||
}
|
||||
#endif /* SFUD_USING_QSPI */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SFUD_FLASH_DEF_H_ */
|
159
MXC_A27-PCB4.5-270T/lib/sfud/inc/snfud_def.h
Normal file
159
MXC_A27-PCB4.5-270T/lib/sfud/inc/snfud_def.h
Normal file
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* This file is part of the Serial Flash Universal Driver Library.
|
||||
*
|
||||
* Copyright (c) 2016-2018, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* 'Software'), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Function: It is the configure head file for this library.
|
||||
* Created on: 2016-04-23
|
||||
*/
|
||||
|
||||
#ifndef _SNFUD_DEF_H_
|
||||
#define _SNFUD_DEF_H_
|
||||
|
||||
#include "board.h"
|
||||
|
||||
|
||||
#ifdef SPI0_QSPI_MODE
|
||||
#define SNFUD_USING_QSPI
|
||||
#endif
|
||||
|
||||
#define SNFUD_CMD_WRITE_DISABLE 0x04
|
||||
#define SNFUD_CMD_WRITE_ENABLE 0x06
|
||||
#define SNFUD_CMD_GET_FEATURE 0x0F
|
||||
#define SNFUD_CMD_SET_FEATURE 0x1F
|
||||
#define SNFUD_CMD_LOCK_REG 0xa0
|
||||
#define SNFUD_CMD_FEATURE_REG 0xb0
|
||||
#define SNFUD_CMD_STATUS_REG 0xc0
|
||||
#define SNFUD_CMD_READ_ID 0x9F
|
||||
#define SNFUD_CMD_PAGE_READ 0x13
|
||||
#define SNFUD_CMD_READ_CACHE 0x03
|
||||
#define SNFUD_CMD_FAST_READ_CACHE 0x0b
|
||||
#define SNFUD_CMD_READ_CACHE_X2 0x3b
|
||||
#define SNFUD_CMD_READ_CACHE_X4 0x6b
|
||||
#define SNFUD_CMD_READ_CACHE_DUAL_IO 0xbb
|
||||
#define SNFUD_CMD_READ_CACHE_QUAD_IO 0xeb
|
||||
#define SNFUD_CMD_PROGRAM_EXEC 0x10
|
||||
#define SNFUD_CMD_PROGRAM_LOAD 0x02
|
||||
#define SNFUD_CMD_PROGRAM_LOAD4 0x32
|
||||
#define SNFUD_CMD_PROGRAM_LOAD_RANDOM 0x84
|
||||
#define SNFUD_CMD_PROGRAM_LOAD_RANDOM4 0xc4
|
||||
#define SNFUD_CMD_BLOCK_ERASE 0xd8
|
||||
#define SNFUD_CMD_RESET 0xFF
|
||||
|
||||
#define SNFUD_ECC_EN (1 << 4)
|
||||
#define SNFUD_QUAD_EN (1 << 0)
|
||||
|
||||
#define SNFUD_PROT_UNLOCK_ALL 0x0
|
||||
#define SNFUD_ECC_UNCORR 0x2
|
||||
#define SNFUD_STATUS_REG_ECC_MASK 0x3
|
||||
#define SNFUD_STATUS_REG_ECC_SHIFT 0x4
|
||||
#define SNFUD_STATUS_REG_PROG_FAIL (1 << 3)
|
||||
#define SNFUD_STATUS_REG_ERASE_FAIL (1 << 2)
|
||||
#define SNFUD_STATUS_REG_WREN (1 << 1)
|
||||
#define SNFUD_STATUS_REG_BUSY (1 << 0)
|
||||
|
||||
#define SNFUD_BBT_HEADER_BLK_COUNT 2
|
||||
#define SNFUD_BBT_BLK_PERCENT 2 //default: 2%
|
||||
#define SNFUD_BBT_HEADER_MASK "SNF BAD BLOCK TABLE" //< 20 bytes.
|
||||
|
||||
/*
|
||||
* To compatible with the spi nor flash interface calls(they have different erase size), we add this macro.
|
||||
* The driver will manage the erase and write operations automatically.
|
||||
*
|
||||
* When write a few data within a block, the driver will first backup the block data with a buffer,
|
||||
* then update the new data to the buffer, and then erase the block, finally write back the buffer data.
|
||||
*/
|
||||
#define SNFUD_ERASE_WRITE_DYNAMIC_MANAGE
|
||||
|
||||
typedef struct spi_nand_plane_select
|
||||
{
|
||||
/* plane select is used for block select */
|
||||
uint32_t rpb; //read page(from nand array to cache) bit.
|
||||
uint32_t rcb; //read cache(from page cache to app buffer) bit.
|
||||
uint32_t plb; //program load(write data to cache) bit.
|
||||
uint32_t peb; //program excute(flush cache to nand array) bit.
|
||||
} sfud_ps;
|
||||
|
||||
|
||||
enum {
|
||||
SNF_BLK_BAD = 0,
|
||||
SNF_BLK_USED,
|
||||
SNF_BLK_GOOD = 0xFF,
|
||||
};
|
||||
|
||||
#define SNFUD_FLASH_DEVICE_TABLE \
|
||||
{ \
|
||||
[0] = {.spi.name = "spi0"}, \
|
||||
}
|
||||
|
||||
static sfud_ps g_SnfPsArray[] = {
|
||||
[0] = {6, 12, 12, 6},
|
||||
};
|
||||
|
||||
// name, MID, DID0, DID0, BBM, bytePerPage, pagePerBlk, blkCnt, spare //PlaneSelect
|
||||
#define SNFUD_FLASH_CHIP_TABLE \
|
||||
{ \
|
||||
{ "DS35Q1GA", 0xE5, 0x71, 0x0, 2, 2048, 64, 1024, 64, -1/* not use */}, \
|
||||
{ "DS35Q2GA", 0xE5, 0x72, 0x0, 2, 2048, 64, 2048, 64, 0}, \
|
||||
}
|
||||
|
||||
|
||||
typedef struct _snf_blk_node {
|
||||
uint8_t status;
|
||||
uint16_t replace; //replace bad block.
|
||||
} snf_blk_node;
|
||||
|
||||
typedef struct _snf_bbt {
|
||||
uint8_t header_mask[32];
|
||||
uint8_t has_mask;
|
||||
snf_blk_node node[];
|
||||
} snf_bbt;
|
||||
|
||||
/* flash chip information */
|
||||
typedef struct {
|
||||
char *name; /**< flash chip name */
|
||||
uint8_t mf_id; /**< manufacturer ID */
|
||||
uint8_t dev_id0; /**< device ID0 */
|
||||
uint8_t dev_id1; /**< device ID1 */
|
||||
uint8_t bbm_type;
|
||||
uint32_t byte_per_page;
|
||||
uint32_t page_per_blk;
|
||||
uint32_t total_blk;
|
||||
uint32_t spare_size;
|
||||
int PsArrayIndex;
|
||||
|
||||
//
|
||||
uint32_t available_blks;
|
||||
uint32_t capacity;
|
||||
uint32_t available_capacity;
|
||||
uint32_t byte_per_blk;
|
||||
uint32_t bbt_header_blk_offset;
|
||||
uint32_t bbt_available_blks;
|
||||
snf_bbt *bbt;
|
||||
sfud_flash *flash;
|
||||
sfud_ps *ps;
|
||||
|
||||
#ifdef SNFUD_ERASE_WRITE_DYNAMIC_MANAGE
|
||||
uint8_t *backup_buf; /* block backup buffer */
|
||||
#endif
|
||||
} snfud_flash_chip;
|
||||
#endif /* _SFUD_CFG_H_ */
|
Reference in New Issue
Block a user