Добавить переносимый драйвер parallel NAND
This commit is contained in:
84
c/parallel-nand/include/parallel_nand_gas.h
Normal file
84
c/parallel-nand/include/parallel_nand_gas.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef PARALLEL_NAND_GAS_H
|
||||
#define PARALLEL_NAND_GAS_H
|
||||
|
||||
#include "parallel_nand.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PNAND_GAS_DEFAULT_BASE 0xE000U
|
||||
#define PNAND_GAS_REGION_REGS 0x0520U
|
||||
#define PNAND_GAS_DATA_OFFSET 0x0100U
|
||||
#define PNAND_GAS_DATA_REGS 1024U
|
||||
#define PNAND_GAS_OOB_OFFSET 0x0500U
|
||||
#define PNAND_GAS_OOB_REGS 32U
|
||||
|
||||
enum {
|
||||
PNAND_GAS_REG_SIGNATURE = 0x0000,
|
||||
PNAND_GAS_REG_VERSION = 0x0001,
|
||||
PNAND_GAS_REG_STATUS = 0x0002,
|
||||
PNAND_GAS_REG_ERROR = 0x0003,
|
||||
PNAND_GAS_REG_COMMAND = 0x0004,
|
||||
PNAND_GAS_REG_PAGE_LO = 0x0005,
|
||||
PNAND_GAS_REG_PAGE_HI = 0x0006,
|
||||
PNAND_GAS_REG_PAGE_MAIN = 0x0007,
|
||||
PNAND_GAS_REG_PAGE_OOB = 0x0008,
|
||||
PNAND_GAS_REG_PAGES_PER_BLOCK = 0x0009,
|
||||
PNAND_GAS_REG_BLOCKS = 0x000A,
|
||||
PNAND_GAS_REG_MANUFACTURER_ID = 0x000B,
|
||||
PNAND_GAS_REG_DEVICE_ID = 0x000C,
|
||||
PNAND_GAS_REG_BAD_BLOCK = 0x000D,
|
||||
PNAND_GAS_REG_GENERATION_LO = 0x000E,
|
||||
PNAND_GAS_REG_GENERATION_HI = 0x000F
|
||||
};
|
||||
|
||||
enum {
|
||||
PNAND_GAS_CMD_NONE = 0,
|
||||
PNAND_GAS_CMD_RESET = 1,
|
||||
PNAND_GAS_CMD_READ_ID = 2,
|
||||
PNAND_GAS_CMD_READ_PAGE = 3
|
||||
};
|
||||
|
||||
#define PNAND_GAS_STATUS_READY 0x0001U
|
||||
#define PNAND_GAS_STATUS_BUSY 0x0002U
|
||||
#define PNAND_GAS_STATUS_PAGE_VALID 0x0004U
|
||||
#define PNAND_GAS_STATUS_BAD_BLOCK 0x0008U
|
||||
#define PNAND_GAS_STATUS_ERROR 0x8000U
|
||||
|
||||
typedef struct {
|
||||
parallel_nand_t *nand;
|
||||
unsigned int base;
|
||||
unsigned int status;
|
||||
int error;
|
||||
unsigned long selected_page;
|
||||
unsigned long generation;
|
||||
unsigned long cached_block;
|
||||
int cached_bad_block;
|
||||
int block_cache_valid;
|
||||
pnand_octet_t id[8];
|
||||
pnand_octet_t main_data[PNAND_MT29F1G08_PAGE_MAIN];
|
||||
pnand_octet_t oob[PNAND_MT29F1G08_PAGE_OOB];
|
||||
} parallel_nand_gas_t;
|
||||
|
||||
void parallel_nand_gas_init(parallel_nand_gas_t *gas,
|
||||
parallel_nand_t *nand, unsigned int base);
|
||||
|
||||
/* Portable GAS callbacks. Values and addresses are exactly 16 bits on wire. */
|
||||
typedef enum {
|
||||
PNAND_GAS_OK = 0,
|
||||
PNAND_GAS_NO_REG,
|
||||
PNAND_GAS_READ_ONLY,
|
||||
PNAND_GAS_REJECTED
|
||||
} parallel_nand_gas_result_t;
|
||||
|
||||
parallel_nand_gas_result_t parallel_nand_gas_read(
|
||||
parallel_nand_gas_t *gas, unsigned int address, unsigned int *value);
|
||||
parallel_nand_gas_result_t parallel_nand_gas_write(
|
||||
parallel_nand_gas_t *gas, unsigned int address, unsigned int value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user