1
2
3
4
5
6
7
8
9
10 #ifndef __LINUX_MTD_ONFI_H
11 #define __LINUX_MTD_ONFI_H
12
13 #include <linux/types.h>
14
15
16 #define ONFI_VERSION_1_0 BIT(1)
17 #define ONFI_VERSION_2_0 BIT(2)
18 #define ONFI_VERSION_2_1 BIT(3)
19 #define ONFI_VERSION_2_2 BIT(4)
20 #define ONFI_VERSION_2_3 BIT(5)
21 #define ONFI_VERSION_3_0 BIT(6)
22 #define ONFI_VERSION_3_1 BIT(7)
23 #define ONFI_VERSION_3_2 BIT(8)
24 #define ONFI_VERSION_4_0 BIT(9)
25
26
27 #define ONFI_FEATURE_16_BIT_BUS (1 << 0)
28 #define ONFI_FEATURE_EXT_PARAM_PAGE (1 << 7)
29
30
31 #define ONFI_TIMING_MODE_0 (1 << 0)
32 #define ONFI_TIMING_MODE_1 (1 << 1)
33 #define ONFI_TIMING_MODE_2 (1 << 2)
34 #define ONFI_TIMING_MODE_3 (1 << 3)
35 #define ONFI_TIMING_MODE_4 (1 << 4)
36 #define ONFI_TIMING_MODE_5 (1 << 5)
37 #define ONFI_TIMING_MODE_UNKNOWN (1 << 6)
38
39
40 #define ONFI_FEATURE_NUMBER 256
41 #define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
42
43
44 #define ONFI_FEATURE_ADDR_READ_RETRY 0x89
45 #define ONFI_FEATURE_ON_DIE_ECC 0x90
46 #define ONFI_FEATURE_ON_DIE_ECC_EN BIT(3)
47
48
49 #define ONFI_SUBFEATURE_PARAM_LEN 4
50
51
52 #define ONFI_OPT_CMD_SET_GET_FEATURES (1 << 2)
53
54 struct nand_onfi_params {
55
56
57 u8 sig[4];
58 __le16 revision;
59 __le16 features;
60 __le16 opt_cmd;
61 u8 reserved0[2];
62 __le16 ext_param_page_length;
63 u8 num_of_param_pages;
64 u8 reserved1[17];
65
66
67 char manufacturer[12];
68 char model[20];
69 u8 jedec_id;
70 __le16 date_code;
71 u8 reserved2[13];
72
73
74 __le32 byte_per_page;
75 __le16 spare_bytes_per_page;
76 __le32 data_bytes_per_ppage;
77 __le16 spare_bytes_per_ppage;
78 __le32 pages_per_block;
79 __le32 blocks_per_lun;
80 u8 lun_count;
81 u8 addr_cycles;
82 u8 bits_per_cell;
83 __le16 bb_per_lun;
84 __le16 block_endurance;
85 u8 guaranteed_good_blocks;
86 __le16 guaranteed_block_endurance;
87 u8 programs_per_page;
88 u8 ppage_attr;
89 u8 ecc_bits;
90 u8 interleaved_bits;
91 u8 interleaved_ops;
92 u8 reserved3[13];
93
94
95 u8 io_pin_capacitance_max;
96 __le16 async_timing_mode;
97 __le16 program_cache_timing_mode;
98 __le16 t_prog;
99 __le16 t_bers;
100 __le16 t_r;
101 __le16 t_ccs;
102 __le16 src_sync_timing_mode;
103 u8 src_ssync_features;
104 __le16 clk_pin_capacitance_typ;
105 __le16 io_pin_capacitance_typ;
106 __le16 input_pin_capacitance_typ;
107 u8 input_pin_capacitance_max;
108 u8 driver_strength_support;
109 __le16 t_int_r;
110 __le16 t_adl;
111 u8 reserved4[8];
112
113
114 __le16 vendor_revision;
115 u8 vendor[88];
116
117 __le16 crc;
118 } __packed;
119
120 #define ONFI_CRC_BASE 0x4F4E
121
122
123 struct onfi_ext_ecc_info {
124 u8 ecc_bits;
125 u8 codeword_size;
126 __le16 bb_per_lun;
127 __le16 block_endurance;
128 u8 reserved[2];
129 } __packed;
130
131 #define ONFI_SECTION_TYPE_0 0
132 #define ONFI_SECTION_TYPE_1 1
133 #define ONFI_SECTION_TYPE_2 2
134 struct onfi_ext_section {
135 u8 type;
136 u8 length;
137 } __packed;
138
139 #define ONFI_EXT_SECTION_MAX 8
140
141
142 struct onfi_ext_param_page {
143 __le16 crc;
144 u8 sig[4];
145 u8 reserved0[10];
146 struct onfi_ext_section sections[ONFI_EXT_SECTION_MAX];
147
148
149
150
151
152
153
154 } __packed;
155
156
157
158
159
160
161
162
163
164
165
166
167 struct onfi_params {
168 int version;
169 u16 tPROG;
170 u16 tBERS;
171 u16 tR;
172 u16 tCCS;
173 u16 async_timing_mode;
174 u16 vendor_revision;
175 u8 vendor[88];
176 };
177
178 #endif