1 #ifndef _SPRD_NFC_REG_V2_H_
\r
2 #define _SPRD_NFC_REG_V2_H_
\r
4 #define NFC_REG_BASE (0x20b00000)
\r
5 #define NFC_START_REG (NFC_REG_BASE)
\r
6 #define NFC_CFG0_REG (NFC_REG_BASE + 0x04)
\r
7 #define NFC_CFG1_REG (NFC_REG_BASE + 0x08)
\r
8 #define NFC_CFG2_REG (NFC_REG_BASE + 0x0C)
\r
9 #define NFC_INT_REG (NFC_REG_BASE + 0x10)
\r
10 #define NFC_TIMING_REG (NFC_REG_BASE + 0x14)
\r
11 #define NFC_TIMING1_REG (NFC_REG_BASE + 0x18)
\r
12 #define NFC_TIMING2_REG (NFC_REG_BASE + 0x1C)
\r
13 #define NFC_MAIN_ADDR_REG (NFC_REG_BASE + 0x20)
\r
14 #define NFC_SPAR_ADDR_REG (NFC_REG_BASE + 0x24)
\r
15 #define NFC_STAT_ADDR_REG (NFC_REG_BASE + 0x28)
\r
16 #define NFC_SEED_ADDR_REG (NFC_REG_BASE + 0x2c)
\r
18 #define NFC_STAT_STSMCH_REG (NFC_REG_BASE + 0x30)
\r
19 #define NFC_TIMEOUT_REG (NFC_REG_BASE + 0x34)
\r
20 #define NFC_CFG3_REG (NFC_REG_BASE + 0x38)
\r
22 #define NFC_STATUS0_REG (NFC_REG_BASE + 0x40)
\r
23 #define NFC_STATUS1_REG (NFC_REG_BASE + 0x44)
\r
24 #define NFC_STATUS2_REG (NFC_REG_BASE + 0x48)
\r
25 #define NFC_STATUS3_REG (NFC_REG_BASE + 0x4C)
\r
26 #define NFC_INST0_REG (NFC_REG_BASE + 0x60)
\r
27 #define NFC_INST1_REG (NFC_REG_BASE + 0x64)
\r
28 #define NFC_INST2_REG (NFC_REG_BASE + 0x68)
\r
29 #define NFC_INST3_REG (NFC_REG_BASE + 0x6C)
\r
30 #define NFC_INST4_REG (NFC_REG_BASE + 0x70)
\r
31 #define NFC_INST5_REG (NFC_REG_BASE + 0x74)
\r
32 #define NFC_INST6_REG (NFC_REG_BASE + 0x78)
\r
33 #define NFC_INST7_REG (NFC_REG_BASE + 0x7C)
\r
34 #define NFC_INST8_REG (NFC_REG_BASE + 0x80)
\r
35 #define NFC_INST9_REG (NFC_REG_BASE + 0x84)
\r
36 #define NFC_INST10_REG (NFC_REG_BASE + 0x88)
\r
37 #define NFC_INST11_REG (NFC_REG_BASE + 0x8C)
\r
39 //NFC_START bit define
\r
40 #define NFC_VALID (BIT_31)
\r
41 #define NFC_RBN (BIT_30)
\r
42 #define NFC_RBN_CNT_OFFSET (28)
\r
43 #define NFC_RBN_CNT_MASK (0x3 << NFC_RBN_CNT_OFFSET)
\r
44 #define NFC_CMD_CLR (BIT_1)
\r
45 #define NFC_START (BIT_0)
\r
47 //NFC_CFG0 bit define
\r
48 #define MAST_ENDIAN_OFFSET (30)
\r
49 #define MAST_ENDIAN_MASK (0x3 << MAST_ENDIAN_OFFSET)
\r
50 #define CS_SEL (BIT_29)
\r
51 #define SECTOR_NUM_OFFSET (24)
\r
52 #define SECTOR_NUM_MASK (0x1f << SECTOR_NUM_OFFSET)
\r
53 #define REPEAT_NUM_OFFSET (16)
\r
54 #define REPEAT_NUM_MASK (0xff << REPEAT_NUM_OFFSET)
\r
55 #define NFC_WPN (BIT_15)
\r
56 #define BUS_WIDTH (BIT_14)
\r
57 #define SPAR_DLEN_CFG (BIT_13)
\r
58 #define SECNUM_IN_INST (BIT_12)
\r
59 #define DETECT_ALL_FF (BIT_11)
\r
60 #define NFC_RW (BIT_8)
\r
61 #define MAIN_SPAR_APT (BIT_6)
\r
62 #define SPAR_USE (BIT_5)
\r
63 #define MAIN_USE (BIT_4)
\r
64 #define ECC_EN (BIT_2)
\r
65 #define NFC_MODE_MASK (0x3)
\r
66 #define NFC_AUTO_MODE (0x0)
\r
67 #define NFC_ONLY_MST_MODE (0x1)
\r
68 #define NFC_ONLY_NAND_MODE (0x2)
\r
69 #define NFC_ONLY_ECC_MODE (0x3)
\r
70 //NFC_CFG1 bit define
\r
71 #define SPAR_INFO_SIZE_OFFSET (24)
\r
72 #define SPAR_INFO_SIZE_MASK (0x7f << SPAR_INFO_SIZE_OFFSET)
\r
73 #define SPAR_SIZE_OFFSET (16)
\r
74 #define SPAR_SIZE_MASK (0x7F << SPAR_SIZE_OFFSET)
\r
75 #define MAIN_SIZE_MASK (0x7ff)
\r
76 //NFC_CFG2 bit define
\r
77 #define SPAR_SECTOR_NUM_OFFSET (24)
\r
78 #define SPAR_SECTOR_NUM_MASK (0x1f << SPAR_SECTOR_NUM_OFFSET)
\r
79 #define SPAR_INFO_POS_OFFSET (16)
\r
80 #define SPAR_INFO_POS_MASK (0x7f << SPAR_INFO_POS_OFFSET)
\r
81 #define ECC_MODE_OFFSET (12)
\r
82 #define ECC_MODE_MASK (0xF << ECC_MODE_OFFSET)
\r
83 #define NFC_ECC_MODE_1BIT (0 << ECC_MODE_OFFSET)
\r
84 #define NFC_ECC_MODE_2BIT (1 << ECC_MODE_OFFSET)
\r
85 #define NFC_ECC_MODE_4BIT (2 << ECC_MODE_OFFSET)
\r
86 #define NFC_ECC_MODE_8BIT (3 << ECC_MODE_OFFSET)
\r
87 #define NFC_ECC_MODE_12BIT (4 << ECC_MODE_OFFSET)
\r
88 #define NFC_ECC_MODE_16BIT (5 << ECC_MODE_OFFSET)
\r
89 #define NFC_ECC_MODE_24BIT (6 << ECC_MODE_OFFSET)
\r
91 #define ECC_STR_SEC_IND_OFFSET (7)
\r
92 #define ECC_STR_SEC_IND_MASK (0x1f << ECC_STR_SEC_IND_OFFSET)
\r
93 #define ECC_POSITON_MASK (0x7f)
\r
94 //NFC_INT bit define
\r
95 #define INT_STSMCH_RAW (BIT_27)
\r
96 #define INT_WP_RAW (BIT_26)
\r
97 #define INT_TO_RAW (BIT_25)
\r
98 #define INT_DONE_RAW (BIT_24)
\r
99 #define INT_STSMCH_STS (BIT_19)
\r
100 #define INT_WP_STS (BIT_18)
\r
101 #define INT_TO_STS (BIT_17)
\r
102 #define INT_DONE_STS (BIT_16)
\r
104 #define INT_STSMCH_CLR (BIT_11)
\r
105 #define INT_WP_CLR (BIT_10)
\r
106 #define INT_TO_CLR (BIT_9)
\r
107 #define INT_DONE_CLR (BIT_8)
\r
109 #define INT_STSMCH_EN (BIT_3)
\r
110 #define INT_WP_EN (BIT_2)
\r
111 #define INT_TO_EN (BIT_1)
\r
112 #define INT_DONE_EN (BIT_0)
\r
116 #define NFC_ACS_OFFSET (27)
\r
117 #define NFC_ACS_MASK (0x1f << NFC_ACS_OFFSET)
\r
118 #define NFC_ACE_OFFSET (22)
\r
119 #define NFC_ACE_MASK (0x1f << NFC_ACE_OFFSET)
\r
120 #define NFC_RWS_OFFSET (16)
\r
121 #define NFC_RWS_MASK (0x3f << NFC_RWS_OFFSET)
\r
122 #define NFC_RWE_OFFSET (11)
\r
123 #define NFC_RWE_MASK (0x1f << NFC_RWS_OFFSET)
\r
124 #define NFC_RWH_OFFSET (6)
\r
125 #define NFC_RWH_MASK (0x1f << NFC_RWH_OFFSET)
\r
126 #define NFC_RWL_MASK (0x3f)
\r
127 //NFC_TIMEOUT bit define
\r
128 #define REPT_CLR_EN (BIT_31)
\r
129 #define TIMETOUT_MASK (0x7fffffff)
\r
131 //NFC_STAT_STSMCH bit define
\r
132 #define NFC_STSMCH_SEL (BIT_17)
\r
133 #define NFC_STSMCH_STOP_EN (BIT_16)
\r
134 #define NFC_STSMCH_MASK_OFFSET (8)
\r
135 #define NFC_STSMCH_VALUE_MASK (0xff)
\r
136 #define ERR_ERR_NUM0_MASK (0x3f)
\r
137 //#define ECC_ERR_NUM_MASK (0x1f)
\r
138 //#define ECC_ERR_STS_SHIFT (5)
\r
139 //#define ECC_ERR_STS_MASK (0x3 << ECC_ERR_STS_SHIFT)
\r
140 #define ECC_ALL_FF (1 << 7)
\r
142 struct sprd_ecc_param {
\r
143 u8 mode; //1, 2, 4, 8,12,16,24
\r
144 u8 ecc_num; //max is 8
\r
145 u8 sp_size; //spare part size
\r
146 u8 ecc_pos; //ecc postion
\r
149 u16 m_size;// main part size;
\r
154 unsigned int sprd_ecc_encode(struct sprd_ecc_param *param);
\r