Root/nandboot/include/nand.h

1/*
2 * nand.h
3 *
4 * Standard NAND Flash definitions.
5 */
6#ifndef __NAND_H__
7#define __NAND_H__
8
9/*
10 * Standard NAND flash commands
11 */
12#define NAND_CMD_READ0 0
13#define NAND_CMD_READ1 1
14#define NAND_CMD_RNDOUT 5
15#define NAND_CMD_PAGEPROG 0x10
16#define NAND_CMD_READOOB 0x50
17#define NAND_CMD_ERASE1 0x60
18#define NAND_CMD_STATUS 0x70
19#define NAND_CMD_STATUS_MULTI 0x71
20#define NAND_CMD_SEQIN 0x80
21#define NAND_CMD_RNDIN 0x85
22#define NAND_CMD_READID 0x90
23#define NAND_CMD_ERASE2 0xd0
24#define NAND_CMD_RESET 0xff
25
26/* Extended commands for large page devices */
27#define NAND_CMD_READSTART 0x30
28#define NAND_CMD_RNDOUTSTART 0xE0
29#define NAND_CMD_CACHEDPROG 0x15
30
31/* Status bits */
32#define NAND_STATUS_FAIL 0x01
33#define NAND_STATUS_FAIL_N1 0x02
34#define NAND_STATUS_TRUE_READY 0x20
35#define NAND_STATUS_READY 0x40
36#define NAND_STATUS_WP 0x80
37
38/*
39 * NAND Flash Manufacturer ID Codes
40 */
41#define NAND_MFR_TOSHIBA 0x98
42#define NAND_MFR_SAMSUNG 0xec
43#define NAND_MFR_FUJITSU 0x04
44#define NAND_MFR_NATIONAL 0x8f
45#define NAND_MFR_RENESAS 0x07
46#define NAND_MFR_STMICRO 0x20
47#define NAND_MFR_HYNIX 0xad
48#define NAND_MFR_MICRON 0x2c
49
50/*
51 * NAND parameter struct
52 */
53struct nand_param {
54    unsigned int bus_width; /* data bus width: 8-bit/16-bit */
55    unsigned int row_cycle; /* row address cycles: 2/3 */
56    unsigned int page_size; /* page size in bytes: 512/2048 */
57    unsigned int oob_size; /* oob size in bytes: 16/64 */
58    unsigned int page_per_block; /* pages per block: 32/64/128 */
59    unsigned int bad_block_pos; /* bad block pos in oob: 0/5 */
60};
61
62/*
63 * NAND routines
64 */
65extern void nand_enable(void);
66extern void nand_disable(void);
67extern int block_is_bad(struct nand_param *nandp, int block);
68extern int nand_read_page(struct nand_param *nandp, int block, int page, unsigned char *dst);
69
70#endif /* __NAND_H__ */
71

Archive Download this file



interactive