bbnand.h
2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef _BBNAND_H_
#define _BBNAND_H_
/*
* This header contains definitions for external nand flash.
*/
/* byte oriented layout description */
#define PI_FLASH_PAGE_DATA_SIZE 512
#define PI_FLASH_OOB_SIZE 16
#define PI_FLASH_PAGE_FULL_SIZE (PI_FLASH_PAGE_DATA_SIZE+PI_FLASH_OOB_SIZE)
#define PI_FLASH_PAGES_PER_BLOCK 32
#define PI_FLASH_PAGE_ADDR_SHIFT 9
#define PI_FLASH_PAGE_PER_BLOCK_POW2 5
/* smart-media specific values */
#define PI_FLASH_PAGE_ECC1_OFFSET 525
#define PI_FLASH_PAGE_ECC2_OFFSET 520
#define PI_FLASH_OOB_ECC1_OFFSET \
(PI_FLASH_PAGE_ECC1_OFFSET-PI_FLASH_PAGE_DATA_SIZE)
#define PI_FLASH_OOB_ECC2_OFFSET \
(PI_FLASH_PAGE_ECC2_OFFSET-PI_FLASH_PAGE_DATA_SIZE)
#define PI_FLASH_OOB_BLOCK_STATUS_OFFSET 5
/* ecc bit locations per smart-media spec:
* These are big-endian specific, and are relative to a 4-byte (word)
* aligned read of the ecc byte locations. The START is from
* the least significant bit in the word, and likewise for the END.
*
* For example, the word aligned read of the ECC1 bytes would
* occur at byte address 524 (PI_FLASH_PAGE_ECC1_OFFSET & ~3).
* The ecc bit positions within the word begin at bit location
* 2 and end at 23 (inclusive, for a total of 22 bits).
*/
#define PI_FLASH_ECC1_BIT_START 2
#define PI_FLASH_ECC2_BIT_START 10
#define PI_FLASH_NUM_ECC_BITS 22
#define PI_FLASH_ECC1_BIT_END \
(PI_FLASH_ECC1_BIT_START + PI_FLASH_NUM_ECC_BITS - 1)
#define PI_FLASH_ECC2_BIT_END \
(PI_FLASH_ECC2_BIT_START + PI_FLASH_NUM_ECC_BITS - 1)
#define NAND_CMD_READ_0 0x00
#define NAND_CMD_READ_1 0x01
#define NAND_CMD_PROGRAM 0x10
#define NAND_CMD_DUMMY_PROGRAM 0x11
#define NAND_CMD_READ_2 0x50
#define NAND_CMD_ERASE_0 0x60
#define NAND_CMD_ERASE_1 0xD0
#define NAND_CMD_STATUS 0x70
#define NAND_CMD_MP_STATUS 0x71
#define NAND_CMD_DATA_INPUT 0x80
#define NAND_CMD_READ_ID 0x90
#define NAND_CMD_RESET 0xff
#define NAND_STATUS_CMD_PASS 0x00
#define NAND_STATUS_CMD_FAIL 0x01
#define NAND_STATUS_READY 0x40
#define NAND_STATUS_BUSY 0x00
#define NAND_STATUS_WRITE_OK 0x80
#define NAND_STATUS_WRITE_NOK 0x00
#endif