]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/mtd/nand/nand_device_info.c
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / drivers / mtd / nand / nand_device_info.c
1 /*
2  * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
3  */
4
5 /*
6  * The code contained herein is licensed under the GNU General Public
7  * License. You may obtain a copy of the GNU General Public License
8  * Version 2 or later at the following locations:
9  *
10  * http://www.opensource.org/licenses/gpl-license.html
11  * http://www.gnu.org/copyleft/gpl.html
12  */
13
14 #include <asm/sizes.h>
15 #include <linux/mtd/nand.h>
16 #include <common.h>
17 #include "nand_device_info.h"
18
19 /*
20  * Type 2
21  */
22 static struct nand_device_info nand_device_info_table_type_2[] =
23 {
24         {
25         .end_of_table             = false,
26         .manufacturer_code        = 0x20,
27         .device_code              = 0xf1,
28         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
29         .chip_size_in_bytes       = 128LL*SZ_1M,
30         .block_size_in_pages      = 64,
31         .page_total_size_in_bytes = 2*SZ_1K + 64,
32         .ecc_strength_in_bits     = 4,
33         .ecc_size_in_bytes        = 512,
34         .data_setup_in_ns         = 30,
35         .data_hold_in_ns          = 20,
36         .address_setup_in_ns      = 25,
37         .gpmi_sample_delay_in_ns  = 6,
38         .tREA_in_ns               = -1,
39         .tRLOH_in_ns              = -1,
40         .tRHOH_in_ns              = -1,
41         "NAND01GW3",
42         },
43         {
44         .end_of_table             = false,
45         .manufacturer_code        = 0xad,
46         .device_code              = 0xf1,
47         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
48         .chip_size_in_bytes       = 128LL*SZ_1M,
49         .block_size_in_pages      = 64,
50         .page_total_size_in_bytes = 2*SZ_1K + 64,
51         .ecc_strength_in_bits     = 4,
52         .ecc_size_in_bytes        = 512,
53         .data_setup_in_ns         = 45,
54         .data_hold_in_ns          = 30,
55         .address_setup_in_ns      = 25,
56         .gpmi_sample_delay_in_ns  = 6,
57         .tREA_in_ns               = -1,
58         .tRLOH_in_ns              = -1,
59         .tRHOH_in_ns              = -1,
60         NULL,
61         },
62         {
63         .end_of_table             = false,
64         .manufacturer_code        = 0x2c,
65         .device_code              = 0xf1,
66         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
67         .chip_size_in_bytes       = 128LL*SZ_1M,
68         .block_size_in_pages      = 64,
69         .page_total_size_in_bytes = 2*SZ_1K + 64,
70         .ecc_strength_in_bits     = 4,
71         .ecc_size_in_bytes        = 512,
72         .data_setup_in_ns         = 30,
73         .data_hold_in_ns          = 20,
74         .address_setup_in_ns      = 10,
75         .gpmi_sample_delay_in_ns  = 6,
76         .tREA_in_ns               = -1,
77         .tRLOH_in_ns              = -1,
78         .tRHOH_in_ns              = -1,
79         NULL,
80         },
81         {
82         .end_of_table             = false,
83         .manufacturer_code        = 0xec,
84         .device_code              = 0xf1,
85         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
86         .chip_size_in_bytes       = 128LL*SZ_1M,
87         .block_size_in_pages      = 64,
88         .page_total_size_in_bytes = 2*SZ_1K + 64,
89         .ecc_strength_in_bits     = 4,
90         .ecc_size_in_bytes        = 512,
91         .data_setup_in_ns         = 35,
92         .data_hold_in_ns          = 25,
93         .address_setup_in_ns      = 0,
94         .gpmi_sample_delay_in_ns  = 6,
95         .tREA_in_ns               = -1,
96         .tRLOH_in_ns              = -1,
97         .tRHOH_in_ns              = -1,
98         "K9F1F08",
99         },
100         {
101         .end_of_table             = false,
102         .manufacturer_code        = 0x98,
103         .device_code              = 0xf1,
104         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
105         .chip_size_in_bytes       = 128LL*SZ_1M,
106         .block_size_in_pages      = 64,
107         .page_total_size_in_bytes = 2*SZ_1K + 64,
108         .ecc_strength_in_bits     = 4,
109         .ecc_size_in_bytes        = 512,
110         .data_setup_in_ns         = 30,
111         .data_hold_in_ns          = 20,
112         .address_setup_in_ns      = 0,
113         .gpmi_sample_delay_in_ns  = 6,
114         .tREA_in_ns               = -1,
115         .tRLOH_in_ns              = -1,
116         .tRHOH_in_ns              = -1,
117         "TC58NVG0S3",
118         },
119         {
120         .end_of_table             = false,
121         .manufacturer_code        = 0x45,
122         .device_code              = 0xf1,
123         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
124         .chip_size_in_bytes       = 128LL*SZ_1M,
125         .block_size_in_pages      = 64,
126         .page_total_size_in_bytes = 2*SZ_1K + 64,
127         .ecc_strength_in_bits     = 4,
128         .ecc_size_in_bytes        = 512,
129         .data_setup_in_ns         = 45,
130         .data_hold_in_ns          = 32,
131         .address_setup_in_ns      = 0,
132         .gpmi_sample_delay_in_ns  = 6,
133         .tREA_in_ns               = -1,
134         .tRLOH_in_ns              = -1,
135         .tRHOH_in_ns              = -1,
136         NULL,
137         },
138         {
139         .end_of_table             = false,
140         .manufacturer_code        = 0x20,
141         .device_code              = 0xda,
142         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
143         .chip_size_in_bytes       = 256LL*SZ_1M,
144         .block_size_in_pages      = 64,
145         .page_total_size_in_bytes = 2*SZ_1K + 64,
146         .ecc_strength_in_bits     = 4,
147         .ecc_size_in_bytes        = 512,
148         .data_setup_in_ns         = 20,
149         .data_hold_in_ns          = 30,
150         .address_setup_in_ns      = 0,
151         .gpmi_sample_delay_in_ns  = 6,
152         .tREA_in_ns               = -1,
153         .tRLOH_in_ns              = -1,
154         .tRHOH_in_ns              = -1,
155         "NAND02GW3",
156         },
157         {
158         .end_of_table             = false,
159         .manufacturer_code        = 0xad,
160         .device_code              = 0xda,
161         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
162         .chip_size_in_bytes       = 256LL*SZ_1M,
163         .block_size_in_pages      = 64,
164         .page_total_size_in_bytes = 2*SZ_1K + 64,
165         .ecc_strength_in_bits     = 4,
166         .ecc_size_in_bytes        = 512,
167         .data_setup_in_ns         = 30,
168         .data_hold_in_ns          = 25,
169         .address_setup_in_ns      = 10,
170         .gpmi_sample_delay_in_ns  = 6,
171         .tREA_in_ns               = -1,
172         .tRLOH_in_ns              = -1,
173         .tRHOH_in_ns              = -1,
174         "HY27UF082G2M, HY27UG082G2M, HY27UG082G1M",
175         },
176         {
177         .end_of_table             = false,
178         .manufacturer_code        = 0x2c,
179         .device_code              = 0xda,
180         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
181         .chip_size_in_bytes       = 256LL*SZ_1M,
182         .block_size_in_pages      = 64,
183         .page_total_size_in_bytes = 2*SZ_1K + 64,
184         .ecc_strength_in_bits     = 4,
185         .ecc_size_in_bytes        = 512,
186         .data_setup_in_ns         = 20,
187         .data_hold_in_ns          = 10,
188         .address_setup_in_ns      = 10,
189         .gpmi_sample_delay_in_ns  = 6,
190         .tREA_in_ns               = -1,
191         .tRLOH_in_ns              = -1,
192         .tRHOH_in_ns              = -1,
193         "MT29F2G08",
194         },
195         {
196         .end_of_table             = false,
197         .manufacturer_code        = 0xec,
198         .device_code              = 0xda,
199         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
200         .chip_size_in_bytes       = 256LL*SZ_1M,
201         .block_size_in_pages      = 64,
202         .page_total_size_in_bytes = 2*SZ_1K + 64,
203         .ecc_strength_in_bits     = 4,
204         .ecc_size_in_bytes        = 512,
205         .data_setup_in_ns         = 20,
206         .data_hold_in_ns          = 10,
207         .address_setup_in_ns      = 20,
208         .gpmi_sample_delay_in_ns  = 6,
209         .tREA_in_ns               = -1,
210         .tRLOH_in_ns              = -1,
211         .tRHOH_in_ns              = -1,
212         "K9F2G08U0M",
213         },
214         {
215         .end_of_table             = false,
216         .manufacturer_code        = 0x98,
217         .device_code              = 0xda,
218         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
219         .chip_size_in_bytes       = 256LL*SZ_1M,
220         .block_size_in_pages      = 64,
221         .page_total_size_in_bytes = 2*SZ_1K + 64,
222         .ecc_strength_in_bits     = 4,
223         .ecc_size_in_bytes        = 512,
224         .data_setup_in_ns         = 20,
225         .data_hold_in_ns          = 30,
226         .address_setup_in_ns      = 0,
227         .gpmi_sample_delay_in_ns  = 6,
228         .tREA_in_ns               = -1,
229         .tRLOH_in_ns              = -1,
230         .tRHOH_in_ns              = -1,
231         "TC58NVG1S3",
232         },
233         {
234         .end_of_table             = false,
235         .manufacturer_code        = 0x45,
236         .device_code              = 0xda,
237         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
238         .chip_size_in_bytes       = 256LL*SZ_1M,
239         .block_size_in_pages      = 64,
240         .page_total_size_in_bytes = 2*SZ_1K + 64,
241         .ecc_strength_in_bits     = 4,
242         .ecc_size_in_bytes        = 512,
243         .data_setup_in_ns         = 45,
244         .data_hold_in_ns          = 32,
245         .address_setup_in_ns      = 0,
246         .gpmi_sample_delay_in_ns  = 6,
247         .tREA_in_ns               = -1,
248         .tRLOH_in_ns              = -1,
249         .tRHOH_in_ns              = -1,
250         NULL,
251         },
252         {
253         .end_of_table             = false,
254         .manufacturer_code        = 0x20,
255         .device_code              = 0xdc,
256         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
257         .chip_size_in_bytes       = 512LL*SZ_1M,
258         .block_size_in_pages      = 64,
259         .page_total_size_in_bytes = 2*SZ_1K + 64,
260         .ecc_strength_in_bits     = 4,
261         .ecc_size_in_bytes        = 512,
262         .data_setup_in_ns         = 45,
263         .data_hold_in_ns          = 30,
264         .address_setup_in_ns      = 10,
265         .gpmi_sample_delay_in_ns  = 6,
266         .tREA_in_ns               = -1,
267         .tRLOH_in_ns              = -1,
268         .tRHOH_in_ns              = -1,
269         NULL,
270         },
271         {
272         .end_of_table             = false,
273         .manufacturer_code        = 0xad,
274         .device_code              = 0xdc,
275         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
276         .chip_size_in_bytes       = 512LL*SZ_1M,
277         .block_size_in_pages      = 64,
278         .page_total_size_in_bytes = 2*SZ_1K + 64,
279         .ecc_strength_in_bits     = 4,
280         .ecc_size_in_bytes        = 512,
281         .data_setup_in_ns         = 45,
282         .data_hold_in_ns          = 30,
283         .address_setup_in_ns      = 10,
284         .gpmi_sample_delay_in_ns  = 10,
285         .tREA_in_ns               = -1,
286         .tRLOH_in_ns              = -1,
287         .tRHOH_in_ns              = -1,
288         "HY27UH084G2M, HY27UG084G2M, HY27UH084G1M",
289         },
290         {
291         .end_of_table             = false,
292         .manufacturer_code        = 0x2c,
293         .device_code              = 0xdc,
294         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
295         .chip_size_in_bytes       = 512LL*SZ_1M,
296         .block_size_in_pages      = 64,
297         .page_total_size_in_bytes = 2*SZ_1K + 64,
298         .ecc_strength_in_bits     = 4,
299         .ecc_size_in_bytes        = 512,
300         .data_setup_in_ns         = 20,
301         .data_hold_in_ns          = 10,
302         .address_setup_in_ns      = 10,
303         .gpmi_sample_delay_in_ns  = 6,
304         .tREA_in_ns               = -1,
305         .tRLOH_in_ns              = -1,
306         .tRHOH_in_ns              = -1,
307         "MT29F4G08",
308         },
309         {
310         .end_of_table             = false,
311         .manufacturer_code        = 0xec,
312         .device_code              = 0xdc,
313         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
314         .chip_size_in_bytes       = 512LL*SZ_1M,
315         .block_size_in_pages      = 64,
316         .page_total_size_in_bytes = 2*SZ_1K + 64,
317         .ecc_strength_in_bits     = 4,
318         .ecc_size_in_bytes        = 512,
319         .data_setup_in_ns         = 25,
320         .data_hold_in_ns          = 25,
321         .address_setup_in_ns      = 20,
322         .gpmi_sample_delay_in_ns  = 6,
323         .tREA_in_ns               = -1,
324         .tRLOH_in_ns              = -1,
325         .tRHOH_in_ns              = -1,
326         NULL,
327         },
328         {
329         .end_of_table             = false,
330         .manufacturer_code        = 0x98,
331         .device_code              = 0xdc,
332         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
333         .chip_size_in_bytes       = 512LL*SZ_1M,
334         .block_size_in_pages      = 64,
335         .page_total_size_in_bytes = 2*SZ_1K + 64,
336         .ecc_strength_in_bits     = 4,
337         .ecc_size_in_bytes        = 512,
338         .data_setup_in_ns         = 25,
339         .data_hold_in_ns          = 25,
340         .address_setup_in_ns      = 0,
341         .gpmi_sample_delay_in_ns  = 6,
342         .tREA_in_ns               = -1,
343         .tRLOH_in_ns              = -1,
344         .tRHOH_in_ns              = -1,
345         "TH58NVG2S3",
346         },
347         {
348         .end_of_table             = false,
349         .manufacturer_code        = 0x45,
350         .device_code              = 0xdc,
351         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
352         .chip_size_in_bytes       = 512LL*SZ_1M,
353         .block_size_in_pages      = 64,
354         .page_total_size_in_bytes = 2*SZ_1K + 64,
355         .ecc_strength_in_bits     = 4,
356         .ecc_size_in_bytes        = 512,
357         .data_setup_in_ns         = 45,
358         .data_hold_in_ns          = 32,
359         .address_setup_in_ns      = 0,
360         .gpmi_sample_delay_in_ns  = 6,
361         .tREA_in_ns               = -1,
362         .tRLOH_in_ns              = -1,
363         .tRHOH_in_ns              = -1,
364         NULL,
365         },
366         {
367         .end_of_table             = false,
368         .manufacturer_code        = 0xad,
369         .device_code              = 0xd3,
370         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
371         .chip_size_in_bytes       = 1LL*SZ_1G,
372         .block_size_in_pages      = 64,
373         .page_total_size_in_bytes = 2*SZ_1K + 64,
374         .ecc_strength_in_bits     = 4,
375         .ecc_size_in_bytes        = 512,
376         .data_setup_in_ns         = 30,
377         .data_hold_in_ns          = 25,
378         .address_setup_in_ns      = 20,
379         .gpmi_sample_delay_in_ns  = 6,
380         .tREA_in_ns               = -1,
381         .tRLOH_in_ns              = -1,
382         .tRHOH_in_ns              = -1,
383         "HY27UH088G2M",
384         },
385         {
386         .end_of_table             = false,
387         .manufacturer_code        = 0x20,
388         .device_code              = 0xd3,
389         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
390         .chip_size_in_bytes       = 1LL*SZ_1G,
391         .block_size_in_pages      = 64,
392         .page_total_size_in_bytes = 2*SZ_1K + 64,
393         .ecc_strength_in_bits     = 4,
394         .ecc_size_in_bytes        = 512,
395         .data_setup_in_ns         = 45,
396         .data_hold_in_ns          = 30,
397         .address_setup_in_ns      = 10,
398         .gpmi_sample_delay_in_ns  = 6,
399         .tREA_in_ns               = -1,
400         .tRLOH_in_ns              = -1,
401         .tRHOH_in_ns              = -1,
402         "NAND08GW3BxANx",
403         },
404         {
405         .end_of_table             = false,
406         .manufacturer_code        = 0x2c,
407         .device_code              = 0xd3,
408         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
409         .chip_size_in_bytes       = 1LL*SZ_1G,
410         .block_size_in_pages      = 64,
411         .page_total_size_in_bytes = 2*SZ_1K + 64,
412         .ecc_strength_in_bits     = 4,
413         .ecc_size_in_bytes        = 512,
414         .data_setup_in_ns         = 25,
415         .data_hold_in_ns          = 15,
416         .address_setup_in_ns      = 10,
417         .gpmi_sample_delay_in_ns  = 6,
418         .tREA_in_ns               = -1,
419         .tRLOH_in_ns              = -1,
420         .tRHOH_in_ns              = -1,
421         "MT29F8G08FABWG",
422         },
423         {
424         .end_of_table             = false,
425         .manufacturer_code        = 0x98,
426         .device_code              = 0xd3,
427         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
428         .chip_size_in_bytes       = 1LL*SZ_1G,
429         .block_size_in_pages      = 64,
430         .page_total_size_in_bytes = 2*SZ_1K + 64,
431         .ecc_strength_in_bits     = 4,
432         .ecc_size_in_bytes        = 512,
433         .data_setup_in_ns         = 45,
434         .data_hold_in_ns          = 32,
435         .address_setup_in_ns      = 0,
436         .gpmi_sample_delay_in_ns  = 6,
437         .tREA_in_ns               = -1,
438         .tRLOH_in_ns              = -1,
439         .tRHOH_in_ns              = -1,
440         NULL,
441         },
442         {
443         .end_of_table             = false,
444         .manufacturer_code        = 0x20,
445         .device_code              = 0xd5,
446         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
447         .chip_size_in_bytes       = 2LL*SZ_1G,
448         .block_size_in_pages      = 64,
449         .page_total_size_in_bytes = 2*SZ_1K + 64,
450         .ecc_strength_in_bits     = 4,
451         .ecc_size_in_bytes        = 512,
452         .data_setup_in_ns         = 45,
453         .data_hold_in_ns          = 30,
454         .address_setup_in_ns      = 10,
455         .gpmi_sample_delay_in_ns  = 6,
456         .tREA_in_ns               = -1,
457         .tRLOH_in_ns              = -1,
458         .tRHOH_in_ns              = -1,
459         NULL,
460         },
461         {
462         .end_of_table             = false,
463         .manufacturer_code        = 0xad,
464         .device_code              = 0xd5,
465         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
466         .chip_size_in_bytes       = 2LL*SZ_1G,
467         .block_size_in_pages      = 64,
468         .page_total_size_in_bytes = 2*SZ_1K + 64,
469         .ecc_strength_in_bits     = 4,
470         .ecc_size_in_bytes        = 512,
471         .data_setup_in_ns         = 25,
472         .data_hold_in_ns          = 30,
473         .address_setup_in_ns      = 10,
474         .gpmi_sample_delay_in_ns  = 6,
475         .tREA_in_ns               = -1,
476         .tRLOH_in_ns              = -1,
477         .tRHOH_in_ns              = -1,
478         NULL,
479         },
480         {
481         .end_of_table             = false,
482         .manufacturer_code        = 0x2c,
483         .device_code              = 0xd5,
484         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
485         .chip_size_in_bytes       = 2LL*SZ_1G,
486         .block_size_in_pages      = 64,
487         .page_total_size_in_bytes = 2*SZ_1K + 64,
488         .ecc_strength_in_bits     = 4,
489         .ecc_size_in_bytes        = 512,
490         .data_setup_in_ns         = 45,
491         .data_hold_in_ns          = 32,
492         .address_setup_in_ns      = 0,
493         .gpmi_sample_delay_in_ns  = 6,
494         .tREA_in_ns               = -1,
495         .tRLOH_in_ns              = -1,
496         .tRHOH_in_ns              = -1,
497         NULL,
498         },
499         {true}
500 };
501
502 /*
503  * Large MLC
504  */
505 static struct nand_device_info nand_device_info_table_large_mlc[] =
506 {
507         {
508         .end_of_table             = false,
509         .manufacturer_code        = 0x98,
510         .device_code              = 0xda,
511         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
512         .chip_size_in_bytes       = 256LL*SZ_1M,
513         .block_size_in_pages      = 128,
514         .page_total_size_in_bytes = 2*SZ_1K + 64,
515         .ecc_strength_in_bits     = 4,
516         .ecc_size_in_bytes        = 512,
517         .data_setup_in_ns         = 20,
518         .data_hold_in_ns          = 30,
519         .address_setup_in_ns      = 0,
520         .gpmi_sample_delay_in_ns  = 6,
521         .tREA_in_ns               = -1,
522         .tRLOH_in_ns              = -1,
523         .tRHOH_in_ns              = -1,
524         "TC58NVG1D4BFT00",
525         },
526         {
527         .end_of_table             = false,
528         .manufacturer_code        = 0x45,
529         .device_code              = 0xda,
530         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
531         .chip_size_in_bytes       = 256LL*SZ_1M,
532         .block_size_in_pages      = 128,
533         .page_total_size_in_bytes = 2*SZ_1K + 64,
534         .ecc_strength_in_bits     = 4,
535         .ecc_size_in_bytes        = 512,
536         .data_setup_in_ns         = 20,
537         .data_hold_in_ns          = 30,
538         .address_setup_in_ns      = 0,
539         .gpmi_sample_delay_in_ns  = 6,
540         .tREA_in_ns               = -1,
541         .tRLOH_in_ns              = -1,
542         .tRHOH_in_ns              = -1,
543         NULL,
544         },
545         {
546         .end_of_table             = false,
547         .manufacturer_code        = 0x45,
548         .device_code              = 0xdc,
549         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
550         .chip_size_in_bytes       = 512LL*SZ_1M,
551         .block_size_in_pages      = 128,
552         .page_total_size_in_bytes = 2*SZ_1K + 64,
553         .ecc_strength_in_bits     = 4,
554         .ecc_size_in_bytes        = 512,
555         .data_setup_in_ns         = 20,
556         .data_hold_in_ns          = 30,
557         .address_setup_in_ns      = 0,
558         .gpmi_sample_delay_in_ns  = 6,
559         .tREA_in_ns               = -1,
560         .tRLOH_in_ns              = -1,
561         .tRHOH_in_ns              = -1,
562         NULL,
563         },
564         {
565         .end_of_table             = false,
566         .manufacturer_code        = 0x98,
567         .device_code              = 0xd3,
568         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
569         .chip_size_in_bytes       = 1LL*SZ_1G,
570         .block_size_in_pages      = 128,
571         .page_total_size_in_bytes = 2*SZ_1K + 64,
572         .ecc_strength_in_bits     = 4,
573         .ecc_size_in_bytes        = 512,
574         .data_setup_in_ns         = 35,
575         .data_hold_in_ns          = 30,
576         .address_setup_in_ns      = 0,
577         .gpmi_sample_delay_in_ns  = 6,
578         .tREA_in_ns               = -1,
579         .tRLOH_in_ns              = -1,
580         .tRHOH_in_ns              = -1,
581         "TH58NVG3D4xFT00",
582         },
583         {
584         .end_of_table             = false,
585         .manufacturer_code        = 0x45,
586         .device_code              = 0xd3,
587         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
588         .chip_size_in_bytes       = 1LL*SZ_1G,
589         .block_size_in_pages      = 128,
590         .page_total_size_in_bytes = 2*SZ_1K + 64,
591         .ecc_strength_in_bits     = 4,
592         .ecc_size_in_bytes        = 512,
593         .data_setup_in_ns         = 35,
594         .data_hold_in_ns          = 20,
595         .address_setup_in_ns      = 0,
596         .gpmi_sample_delay_in_ns  = 6,
597         .tREA_in_ns               = -1,
598         .tRLOH_in_ns              = -1,
599         .tRHOH_in_ns              = -1,
600         NULL,
601         },
602         {
603         .end_of_table             = false,
604         .manufacturer_code        = 0x98,
605         .device_code              = 0xd5,
606         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
607         .chip_size_in_bytes       = 2LL*SZ_1G,
608         .block_size_in_pages      = 128,
609         .page_total_size_in_bytes = 2*SZ_1K + 64,
610         .ecc_strength_in_bits     = 4,
611         .ecc_size_in_bytes        = 512,
612         .data_setup_in_ns         = 35,
613         .data_hold_in_ns          = 15,
614         .address_setup_in_ns      = 0,
615         .gpmi_sample_delay_in_ns  = 6,
616         .tREA_in_ns               = -1,
617         .tRLOH_in_ns              = -1,
618         .tRHOH_in_ns              = -1,
619         "TH58NVG4D4xFT00",
620         },
621         {
622         .end_of_table             = false,
623         .manufacturer_code        = 0x45,
624         .device_code              = 0xd5,
625         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
626         .chip_size_in_bytes       = 2LL*SZ_1G,
627         .block_size_in_pages      = 128,
628         .page_total_size_in_bytes = 2*SZ_1K + 64,
629         .ecc_strength_in_bits     = 4,
630         .ecc_size_in_bytes        = 512,
631         .data_setup_in_ns         = 35,
632         .data_hold_in_ns          = 15,
633         .address_setup_in_ns      = 0,
634         .gpmi_sample_delay_in_ns  = 6,
635         .tREA_in_ns               = -1,
636         .tRLOH_in_ns              = -1,
637         .tRHOH_in_ns              = -1,
638         NULL,
639         },
640         {
641         .end_of_table             = false,
642         .manufacturer_code        = 0x98,
643         .device_code              = 0xdc,
644         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
645         .chip_size_in_bytes       = 512LL*SZ_1M,
646         .block_size_in_pages      = 128,
647         .page_total_size_in_bytes = 2*SZ_1K + 64,
648         .ecc_strength_in_bits     = 4,
649         .ecc_size_in_bytes        = 512,
650         .data_setup_in_ns         = 20,
651         .data_hold_in_ns          = 30,
652         .address_setup_in_ns      = 0,
653         .gpmi_sample_delay_in_ns  = 6,
654         .tREA_in_ns               = -1,
655         .tRLOH_in_ns              = -1,
656         .tRHOH_in_ns              = -1,
657         "TC58NVG2D4BFT00",
658         },
659         {
660         .end_of_table             = false,
661         .manufacturer_code        = 0xec,
662         .device_code              = 0xdc,
663         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
664         .chip_size_in_bytes       = 512LL*SZ_1M,
665         .block_size_in_pages      = 128,
666         .page_total_size_in_bytes = 2*SZ_1K + 64,
667         .ecc_strength_in_bits     = 4,
668         .ecc_size_in_bytes        = 512,
669         .data_setup_in_ns         = 25,
670         .data_hold_in_ns          = 15,
671         .address_setup_in_ns      = 25,
672         .gpmi_sample_delay_in_ns  = 6,
673         .tREA_in_ns               = -1,
674         .tRLOH_in_ns              = -1,
675         .tRHOH_in_ns              = -1,
676         "K9G4G08U0M",
677         },
678         {
679         .end_of_table             = false,
680         .manufacturer_code        = 0xad,
681         .device_code              = 0xdc,
682         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
683         .chip_size_in_bytes       = 512LL*SZ_1M,
684         .block_size_in_pages      = 128,
685         .page_total_size_in_bytes = 2*SZ_1K + 64,
686         .ecc_strength_in_bits     = 4,
687         .ecc_size_in_bytes        = 512,
688         .data_setup_in_ns         = 45,
689         .data_hold_in_ns          = 25,
690         .address_setup_in_ns      = 50,
691         .gpmi_sample_delay_in_ns  = 6,
692         .tREA_in_ns               = -1,
693         .tRLOH_in_ns              = -1,
694         .tRHOH_in_ns              = -1,
695         "HY27UT084G2M, HY27UU088G5M",
696         },
697         {
698         .end_of_table             = false,
699         .manufacturer_code        = 0x20,
700         .device_code              = 0xdc,
701         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
702         .chip_size_in_bytes       = 512LL*SZ_1M,
703         .block_size_in_pages      = 128,
704         .page_total_size_in_bytes = 2*SZ_1K + 64,
705         .ecc_strength_in_bits     = 4,
706         .ecc_size_in_bytes        = 512,
707         .data_setup_in_ns         = 40,
708         .data_hold_in_ns          = 20,
709         .address_setup_in_ns      = 30,
710         .gpmi_sample_delay_in_ns  = 6,
711         .tREA_in_ns               = -1,
712         .tRLOH_in_ns              = -1,
713         .tRHOH_in_ns              = -1,
714         "NAND04GW3C2AN1E",
715         },
716         {
717         .end_of_table             = false,
718         .manufacturer_code        = 0xec,
719         .device_code              = 0xd3,
720         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
721         .chip_size_in_bytes       = 1LL*SZ_1G,
722         .block_size_in_pages      = 128,
723         .page_total_size_in_bytes = 2*SZ_1K + 64,
724         .ecc_strength_in_bits     = 4,
725         .ecc_size_in_bytes        = 512,
726         .data_setup_in_ns         = 20,
727         .data_hold_in_ns          = 15,
728         .address_setup_in_ns      = 20,
729         .gpmi_sample_delay_in_ns  = 6,
730         .tREA_in_ns               = -1,
731         .tRLOH_in_ns              = -1,
732         .tRHOH_in_ns              = -1,
733         "K9G8G08U0M, K9HAG08U1M",
734         },
735         {
736         .end_of_table             = false,
737         .manufacturer_code        = 0xad,
738         .device_code              = 0xd3,
739         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
740         .chip_size_in_bytes       = 1LL*SZ_1G,
741         .block_size_in_pages      = 128,
742         .page_total_size_in_bytes = 2*SZ_1K + 64,
743         .ecc_strength_in_bits     = 4,
744         .ecc_size_in_bytes        = 512,
745         .data_setup_in_ns         = 60,
746         .data_hold_in_ns          = 30,
747         .address_setup_in_ns      = 50,
748         .gpmi_sample_delay_in_ns  = 6,
749         .tREA_in_ns               = -1,
750         .tRLOH_in_ns              = -1,
751         .tRHOH_in_ns              = -1,
752         "HY27UV08AG5M",
753         },
754         {
755         .end_of_table             = false,
756         .manufacturer_code        = 0x2c,
757         .device_code              = 0xd3,
758         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
759         .chip_size_in_bytes       = 1LL*SZ_1G,
760         .block_size_in_pages      = 128,
761         .page_total_size_in_bytes = 2*SZ_1K + 64,
762         .ecc_strength_in_bits     = 4,
763         .ecc_size_in_bytes        = 512,
764         .data_setup_in_ns         = 15,
765         .data_hold_in_ns          = 15,
766         .address_setup_in_ns      = 15,
767         .gpmi_sample_delay_in_ns  = 6,
768         .tREA_in_ns               = -1,
769         .tRLOH_in_ns              = -1,
770         .tRHOH_in_ns              = -1,
771         "Intel JS29F08G08AAMiB1 and Micron MT29F8G08MAA; "
772         "Intel JS29F08G08CAMiB1 and Micron MT29F16G08QAA",
773         },
774         {
775         .end_of_table             = false,
776         .manufacturer_code        = 0xec,
777         .device_code              = 0xd5,
778         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
779         .chip_size_in_bytes       = 2LL*SZ_1G,
780         .block_size_in_pages      = 128,
781         .page_total_size_in_bytes = 2*SZ_1K + 64,
782         .ecc_strength_in_bits     = 4,
783         .ecc_size_in_bytes        = 512,
784         .data_setup_in_ns         = 20,
785         .data_hold_in_ns          = 15,
786         .address_setup_in_ns      = 20,
787         .gpmi_sample_delay_in_ns  = 6,
788         .tREA_in_ns               = -1,
789         .tRLOH_in_ns              = -1,
790         .tRHOH_in_ns              = -1,
791         "K9LAG08U0M K9HBG08U1M K9GAG08U0M",
792         },
793         {
794         .end_of_table             = false,
795         .manufacturer_code        = 0x2c,
796         .device_code              = 0xd5,
797         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
798         .chip_size_in_bytes       = 2LL*SZ_1G,
799         .block_size_in_pages      = 128,
800         .page_total_size_in_bytes = 2*SZ_1K + 64,
801         .ecc_strength_in_bits     = 4,
802         .ecc_size_in_bytes        = 512,
803         .data_setup_in_ns         = 15,
804         .data_hold_in_ns          = 10,
805         .address_setup_in_ns      = 15,
806         .gpmi_sample_delay_in_ns  = 6,
807         .tREA_in_ns               = -1,
808         .tRLOH_in_ns              = -1,
809         .tRHOH_in_ns              = -1,
810         "Intel JS29F32G08FAMiB1 and Micron MT29F32G08TAA",
811         },
812         {
813         .end_of_table             = false,
814         .manufacturer_code        = 0x2c,
815         .device_code              = 0xdc,
816         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
817         .chip_size_in_bytes       = 512LL*SZ_1M,
818         .block_size_in_pages      = 128,
819         .page_total_size_in_bytes = 2*SZ_1K + 64,
820         .ecc_strength_in_bits     = 4,
821         .ecc_size_in_bytes        = 512,
822         .data_setup_in_ns         = 20,
823         .data_hold_in_ns          = 20,
824         .address_setup_in_ns      = 20,
825         .gpmi_sample_delay_in_ns  = 6,
826         .tREA_in_ns               = -1,
827         .tRLOH_in_ns              = -1,
828         .tRHOH_in_ns              = -1,
829         "MT29F4G08",
830         },
831         {
832         .end_of_table             = false,
833         .manufacturer_code        = 0x89,
834         .device_code              = 0xd3,
835         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
836         .chip_size_in_bytes       = 1LL*SZ_1G,
837         .block_size_in_pages      = 128,
838         .page_total_size_in_bytes = 2*SZ_1K + 64,
839         .ecc_strength_in_bits     = 4,
840         .ecc_size_in_bytes        = 512,
841         .data_setup_in_ns         = 15,
842         .data_hold_in_ns          = 10,
843         .address_setup_in_ns      = 15,
844         .gpmi_sample_delay_in_ns  = 6,
845         .tREA_in_ns               = -1,
846         .tRLOH_in_ns              = -1,
847         .tRHOH_in_ns              = -1,
848         "JS29F08G08AAMiB2, JS29F08G08CAMiB2",
849         },
850         {
851         .end_of_table             = false,
852         .manufacturer_code        = 0x89,
853         .device_code              = 0xd5,
854         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
855         .chip_size_in_bytes       = 2LL*SZ_1G,
856         .block_size_in_pages      = 128,
857         .page_total_size_in_bytes = 2*SZ_1K + 64,
858         .ecc_strength_in_bits     = 4,
859         .ecc_size_in_bytes        = 512,
860         .data_setup_in_ns         = 15,
861         .data_hold_in_ns          = 10,
862         .address_setup_in_ns      = 15,
863         .gpmi_sample_delay_in_ns  = 6,
864         .tREA_in_ns               = -1,
865         .tRLOH_in_ns              = -1,
866         .tRHOH_in_ns              = -1,
867         "JS29F32G08FAMiB2",
868         },
869         {
870         .end_of_table             = false,
871         .manufacturer_code        = 0xad,
872         .device_code              = 0xd5,
873         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
874         .chip_size_in_bytes       = 2LL*SZ_1G,
875         .block_size_in_pages      = 128,
876         .page_total_size_in_bytes = 2*SZ_1K + 64,
877         .ecc_strength_in_bits     = 4,
878         .ecc_size_in_bytes        = 512,
879         .data_setup_in_ns         = 15,
880         .data_hold_in_ns          = 10,
881         .address_setup_in_ns      = 20,
882         .gpmi_sample_delay_in_ns  = 6,
883         .tREA_in_ns               = -1,
884         .tRLOH_in_ns              = -1,
885         .tRHOH_in_ns              = -1,
886         "HY27UW08CGFM",
887         },
888         {true}
889 };
890
891 /*
892  * Type 7
893  */
894 static struct nand_device_info nand_device_info_table_type_7[] =
895 {
896         {
897         .end_of_table             = false,
898         .manufacturer_code        = 0x2c,
899         .device_code              = 0xd3,
900         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
901         .chip_size_in_bytes       = 1LL*SZ_1G,
902         .block_size_in_pages      = 64,
903         .page_total_size_in_bytes = 2*SZ_1K + 64,
904         .ecc_strength_in_bits     = 4,
905         .ecc_size_in_bytes        = 512,
906         .data_setup_in_ns         = 25,
907         .data_hold_in_ns          = 15,
908         .address_setup_in_ns      = 10,
909         .gpmi_sample_delay_in_ns  = 6,
910         .tREA_in_ns               = -1,
911         .tRLOH_in_ns              = -1,
912         .tRHOH_in_ns              = -1,
913         "MT29F8G08FABWG",
914         },
915         {
916         .end_of_table             = false,
917         .manufacturer_code        = 0x2c,
918         .device_code              = 0xdc,
919         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
920         .chip_size_in_bytes       = 512LL*SZ_1M,
921         .block_size_in_pages      = 64,
922         .page_total_size_in_bytes = 2*SZ_1K + 64,
923         .ecc_strength_in_bits     = 4,
924         .ecc_size_in_bytes        = 512,
925         .data_setup_in_ns         = 20,
926         .data_hold_in_ns          = 10,
927         .address_setup_in_ns      = 10,
928         .gpmi_sample_delay_in_ns  = 6,
929         .tREA_in_ns               = -1,
930         .tRLOH_in_ns              = -1,
931         .tRHOH_in_ns              = -1,
932         "MT29F4G08AAA",
933         },
934         {
935         .end_of_table             = false,
936         .manufacturer_code        = 0xec,
937         .device_code              = 0xdc,
938         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
939         .chip_size_in_bytes       = 512LL*SZ_1M,
940         .block_size_in_pages      = 64,
941         .page_total_size_in_bytes = 2*SZ_1K + 64,
942         .ecc_strength_in_bits     = 4,
943         .ecc_size_in_bytes        = 512,
944         .data_setup_in_ns         = 15,
945         .data_hold_in_ns          = 12,
946         .address_setup_in_ns      = 25,
947         .gpmi_sample_delay_in_ns  = 6,
948         .tREA_in_ns               = -1,
949         .tRLOH_in_ns              = -1,
950         .tRHOH_in_ns              = -1,
951         "K9F4G08",
952         },
953         {
954         .end_of_table             = false,
955         .manufacturer_code        = 0xec,
956         .device_code              = 0xd3,
957         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
958         .chip_size_in_bytes       = 1LL*SZ_1G,
959         .block_size_in_pages      = 64,
960         .page_total_size_in_bytes = 2*SZ_1K + 64,
961         .ecc_strength_in_bits     = 4,
962         .ecc_size_in_bytes        = 512,
963         .data_setup_in_ns         = 25,
964         .data_hold_in_ns          = 15,
965         .address_setup_in_ns      = 35,
966         .gpmi_sample_delay_in_ns  = 6,
967         .tREA_in_ns               = -1,
968         .tRLOH_in_ns              = -1,
969         .tRHOH_in_ns              = -1,
970         "K9K8G08UXM, K9NBG08U5A, K9WAG08U1A",
971         },
972         {
973         .end_of_table             = false,
974         .manufacturer_code        = 0xec,
975         .device_code              = 0xd5,
976         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
977         .chip_size_in_bytes       = 2LL*SZ_1G,
978         .block_size_in_pages      = 64,
979         .page_total_size_in_bytes = 2*SZ_1K + 64,
980         .ecc_strength_in_bits     = 4,
981         .ecc_size_in_bytes        = 512,
982         .data_setup_in_ns         = 15,
983         .data_hold_in_ns          = 12,
984         .address_setup_in_ns      = 25,
985         .gpmi_sample_delay_in_ns  = 6,
986         .tREA_in_ns               = -1,
987         .tRLOH_in_ns              = -1,
988         .tRHOH_in_ns              = -1,
989         "K9WAG08UXM",
990         },
991         {
992         .end_of_table             = false,
993         .manufacturer_code        = 0xec,
994         .device_code              = 0xda,
995         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
996         .chip_size_in_bytes       = 256LL*SZ_1M,
997         .block_size_in_pages      = 64,
998         .page_total_size_in_bytes = 2*SZ_1K + 64,
999         .ecc_strength_in_bits     = 4,
1000         .ecc_size_in_bytes        = 512,
1001         .data_setup_in_ns         = 20,
1002         .data_hold_in_ns          = 10,
1003         .address_setup_in_ns      = 20,
1004         .gpmi_sample_delay_in_ns  = 6,
1005         .tREA_in_ns               = -1,
1006         .tRLOH_in_ns              = -1,
1007         .tRHOH_in_ns              = -1,
1008         "K9F2G08U0A",
1009         },
1010         {
1011         .end_of_table             = false,
1012         .manufacturer_code        = 0xec,
1013         .device_code              = 0xf1,
1014         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
1015         .chip_size_in_bytes       = 128LL*SZ_1M,
1016         .block_size_in_pages      = 64,
1017         .page_total_size_in_bytes = 2*SZ_1K + 64,
1018         .ecc_strength_in_bits     = 4,
1019         .ecc_size_in_bytes        = 512,
1020         .data_setup_in_ns         = 15,
1021         .data_hold_in_ns          = 12,
1022         .address_setup_in_ns      = 20,
1023         .gpmi_sample_delay_in_ns  = 6,
1024         .tREA_in_ns               = -1,
1025         .tRLOH_in_ns              = -1,
1026         .tRHOH_in_ns              = -1,
1027         "K9F1F08",
1028         },
1029         {true}
1030 };
1031
1032 /*
1033  * Type 8
1034  */
1035 static struct nand_device_info nand_device_info_table_type_8[] =
1036 {
1037         {
1038         .end_of_table             = false,
1039         .manufacturer_code        = 0xec,
1040         .device_code              = 0xd5,
1041         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1042         .chip_size_in_bytes       = 2LL*SZ_1G,
1043         .block_size_in_pages      = 128,
1044         .page_total_size_in_bytes = 4*SZ_1K + 128,
1045         .ecc_strength_in_bits     = 4,
1046         .ecc_size_in_bytes        = 512,
1047         .data_setup_in_ns         = 15,
1048         .data_hold_in_ns          = 10,
1049         .address_setup_in_ns      = 20,
1050         .gpmi_sample_delay_in_ns  = 6,
1051         .tREA_in_ns               = -1,
1052         .tRLOH_in_ns              = -1,
1053         .tRHOH_in_ns              = -1,
1054         "K9GAG08U0M",
1055         },
1056         {
1057         .end_of_table             = false,
1058         .manufacturer_code        = 0xec,
1059         .device_code              = 0xd7,
1060         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1061         .chip_size_in_bytes       = 4LL*SZ_1G,
1062         .block_size_in_pages      = 128,
1063         .page_total_size_in_bytes = 4*SZ_1K + 128,
1064         .ecc_strength_in_bits     = 4,
1065         .ecc_size_in_bytes        = 512,
1066         .data_setup_in_ns         = 15,
1067         .data_hold_in_ns          = 15,
1068         .address_setup_in_ns      = 25,
1069         .gpmi_sample_delay_in_ns  = 6,
1070         .tREA_in_ns               = -1,
1071         .tRLOH_in_ns              = -1,
1072         .tRHOH_in_ns              = -1,
1073         "K9LBG08U0M (32Gb), K9HCG08U1M (64Gb), K9MDG08U5M (128Gb)",
1074         },
1075         {
1076         .end_of_table             = false,
1077         .manufacturer_code        = 0xad,
1078         .device_code              = 0xd5,
1079         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1080         .chip_size_in_bytes       = 2LL*SZ_1G,
1081         .block_size_in_pages      = 128,
1082         .page_total_size_in_bytes = 4*SZ_1K + 128,
1083         .ecc_strength_in_bits     = 4,
1084         .ecc_size_in_bytes        = 512,
1085         .data_setup_in_ns         = 20,
1086         .data_hold_in_ns          = 20,
1087         .address_setup_in_ns      = 20,
1088         .gpmi_sample_delay_in_ns  = 0,
1089         .tREA_in_ns               = -1,
1090         .tRLOH_in_ns              = -1,
1091         .tRHOH_in_ns              = -1,
1092         "H27UAG, H27UBG",
1093         },
1094         {
1095         .end_of_table             = false,
1096         .manufacturer_code        = 0xad,
1097         .device_code              = 0xd7,
1098         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1099         .chip_size_in_bytes       = 4LL*SZ_1G,
1100         .block_size_in_pages      = 128,
1101         .page_total_size_in_bytes = 4*SZ_1K + 128,
1102         .ecc_strength_in_bits     = 4,
1103         .ecc_size_in_bytes        = 512,
1104         .data_setup_in_ns         = 23,
1105         .data_hold_in_ns          = 20,
1106         .address_setup_in_ns      = 25,
1107         .gpmi_sample_delay_in_ns  = 0,
1108         .tREA_in_ns               = -1,
1109         .tRLOH_in_ns              = -1,
1110         .tRHOH_in_ns              = -1,
1111         "H27UCG",
1112         },
1113         {true}
1114 };
1115
1116 /*
1117  * Type 9
1118  */
1119 static struct nand_device_info nand_device_info_table_type_9[] =
1120 {
1121         {
1122         .end_of_table             = false,
1123         .manufacturer_code        = 0x98,
1124         .device_code              = 0xd3,
1125         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1126         .chip_size_in_bytes       = 1LL*SZ_1G,
1127         .block_size_in_pages      = 128,
1128         .page_total_size_in_bytes = 4*SZ_1K + 218,
1129         .ecc_strength_in_bits     = 8,
1130         .ecc_size_in_bytes        = 512,
1131         .data_setup_in_ns         = 15,
1132         .data_hold_in_ns          = 15,
1133         .address_setup_in_ns      = 10,
1134         .gpmi_sample_delay_in_ns  = 6,
1135         .tREA_in_ns               = -1,
1136         .tRLOH_in_ns              = -1,
1137         .tRHOH_in_ns              = -1,
1138         "TC58NVG3D1DTG00",
1139         },
1140         {
1141         .end_of_table             = false,
1142         .manufacturer_code        = 0x98,
1143         .device_code              = 0xd5,
1144         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1145         .chip_size_in_bytes       = 2LL*SZ_1G,
1146         .block_size_in_pages      = 128,
1147         .page_total_size_in_bytes = 4*SZ_1K + 218,
1148         .ecc_strength_in_bits     = 8,
1149         .ecc_size_in_bytes        = 512,
1150         .data_setup_in_ns         = 15,
1151         .data_hold_in_ns          = 15,
1152         .address_setup_in_ns      = 10,
1153         .gpmi_sample_delay_in_ns  = 6,
1154         .tREA_in_ns               = -1,
1155         .tRLOH_in_ns              = -1,
1156         .tRHOH_in_ns              = -1,
1157         "TC58NVG4D1DTG00",
1158         },
1159         {
1160         .end_of_table             = false,
1161         .manufacturer_code        = 0x98,
1162         .device_code              = 0xd7,
1163         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1164         .chip_size_in_bytes       = 4LL*SZ_1G,
1165         .block_size_in_pages      = 128,
1166         .page_total_size_in_bytes = 4*SZ_1K + 218,
1167         .ecc_strength_in_bits     = 8,
1168         .ecc_size_in_bytes        = 512,
1169         .data_setup_in_ns         = 15,
1170         .data_hold_in_ns          = 15,
1171         .address_setup_in_ns      = 10,
1172         .gpmi_sample_delay_in_ns  = 6,
1173         .tREA_in_ns               = -1,
1174         .tRLOH_in_ns              = -1,
1175         .tRHOH_in_ns              = -1,
1176         "TH58NVG6D1DTG20",
1177         },
1178         {
1179         .end_of_table             = false,
1180         .manufacturer_code        = 0x89,
1181         .device_code              = 0xd5,
1182         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1183         .chip_size_in_bytes       = 2LL*SZ_1G,
1184         .block_size_in_pages      = 128,
1185         .page_total_size_in_bytes = 4*SZ_1K + 218,
1186         .ecc_strength_in_bits     = 8,
1187         .ecc_size_in_bytes        = 512,
1188         .data_setup_in_ns         = 10,
1189         .data_hold_in_ns          = 10,
1190         .address_setup_in_ns      = 15,
1191         .gpmi_sample_delay_in_ns  = 6,
1192         .tREA_in_ns               = -1,
1193         .tRLOH_in_ns              = -1,
1194         .tRHOH_in_ns              = -1,
1195         "JS29F16G08AAMC1, JS29F32G08CAMC1",
1196         },
1197         {
1198         .end_of_table             = false,
1199         .manufacturer_code        = 0x2c,
1200         .device_code              = 0xd5,
1201         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1202         .chip_size_in_bytes       = 2LL*SZ_1G,
1203         .block_size_in_pages      = 128,
1204         .page_total_size_in_bytes = 4*SZ_1K + 218,
1205         .ecc_strength_in_bits     = 8,
1206         .ecc_size_in_bytes        = 512,
1207         .data_setup_in_ns         = 15,
1208         .data_hold_in_ns          = 10,
1209         .address_setup_in_ns      = 15,
1210         .gpmi_sample_delay_in_ns  = 6,
1211         .tREA_in_ns               = -1,
1212         .tRLOH_in_ns              = -1,
1213         .tRHOH_in_ns              = -1,
1214         "MT29F16G08MAA, MT29F32G08QAA",
1215         },
1216         {
1217         .end_of_table             = false,
1218         .manufacturer_code        = 0x2c,
1219         .device_code              = 0xd7,
1220         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1221         .chip_size_in_bytes       = 4LL*SZ_1G,
1222         .block_size_in_pages      = 128,
1223         .page_total_size_in_bytes = 4*SZ_1K + 218,
1224         .ecc_strength_in_bits     = 8,
1225         .ecc_size_in_bytes        = 512,
1226         .data_setup_in_ns         = 15,
1227         .data_hold_in_ns          = 10,
1228         .address_setup_in_ns      = 15,
1229         .gpmi_sample_delay_in_ns  = 6,
1230         .tREA_in_ns               = -1,
1231         .tRLOH_in_ns              = -1,
1232         .tRHOH_in_ns              = -1,
1233         "MT29F64G08TAA (32Gb), MT29F32G08CBAAA (32Gb) MT29F64G08CFAAA (64Gb)",
1234         },
1235         {
1236         .end_of_table             = false,
1237         .manufacturer_code        = 0x2c,
1238         .device_code              = 0xd9,
1239         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1240         .chip_size_in_bytes       = 8LL*SZ_1G,
1241         .block_size_in_pages      = 128,
1242         .page_total_size_in_bytes = 4*SZ_1K + 218,
1243         .ecc_strength_in_bits     = 8,
1244         .ecc_size_in_bytes        = 512,
1245         .data_setup_in_ns         = 10,
1246         .data_hold_in_ns          = 10,
1247         .address_setup_in_ns      = 15,
1248         .gpmi_sample_delay_in_ns  = 6,
1249         .tREA_in_ns               = -1,
1250         .tRLOH_in_ns              = -1,
1251         .tRHOH_in_ns              = -1,
1252         "MT29F128G08CJAAA",
1253         },
1254         {
1255         .end_of_table             = false,
1256         .manufacturer_code        = 0x89,
1257         .device_code              = 0xd7,
1258         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1259         .chip_size_in_bytes       = 4LL*SZ_1G,
1260         .block_size_in_pages      = 128,
1261         .page_total_size_in_bytes = 4*SZ_1K + 218,
1262         .ecc_strength_in_bits     = 8,
1263         .ecc_size_in_bytes        = 512,
1264         .data_setup_in_ns         = 10,
1265         .data_hold_in_ns          = 10,
1266         .address_setup_in_ns      = 15,
1267         .gpmi_sample_delay_in_ns  = 6,
1268         .tREA_in_ns               = -1,
1269         .tRLOH_in_ns              = -1,
1270         .tRHOH_in_ns              = -1,
1271         "JSF64G08FAMC1",
1272         },
1273         {
1274         .end_of_table             = false,
1275         .manufacturer_code        = 0xec,
1276         .device_code              = 0xd7,
1277         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1278         .chip_size_in_bytes       = 4LL*SZ_1G,
1279         .block_size_in_pages      = 128,
1280         .page_total_size_in_bytes = 4*SZ_1K + 218,
1281         .ecc_strength_in_bits     = 8,
1282         .ecc_size_in_bytes        = 512,
1283         .data_setup_in_ns         = 20,
1284         .data_hold_in_ns          = 10,
1285         .address_setup_in_ns      = 25,
1286         .gpmi_sample_delay_in_ns  = 6,
1287         .tREA_in_ns               = -1,
1288         .tRLOH_in_ns              = -1,
1289         .tRHOH_in_ns              = -1,
1290         "K9LBG08U0D",
1291         },
1292         {
1293         .end_of_table             = false,
1294         .manufacturer_code        = 0xec,
1295         .device_code              = 0xd5,
1296         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1297         .chip_size_in_bytes       = 2LL*SZ_1G,
1298         .block_size_in_pages      = 128,
1299         .page_total_size_in_bytes = 4*SZ_1K + 218,
1300         .ecc_strength_in_bits     = 8,
1301         .ecc_size_in_bytes        = 512,
1302         .data_setup_in_ns         = 20,
1303         .data_hold_in_ns          = 10,
1304         .address_setup_in_ns      = 20,
1305         .gpmi_sample_delay_in_ns  = 6,
1306         .tREA_in_ns               = -1,
1307         .tRLOH_in_ns              = -1,
1308         .tRHOH_in_ns              = -1,
1309         "K9GAG08U0D, K9LBG08U1D, K9HCG08U5D",
1310         },
1311         {true}
1312 };
1313
1314 /*
1315  * Type 10
1316  */
1317 static struct nand_device_info nand_device_info_table_type_10[] =
1318 {
1319         {
1320         .end_of_table             = false,
1321         .manufacturer_code        = 0xec,
1322         .device_code              = 0xd3,
1323         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
1324         .chip_size_in_bytes       = 1LL*SZ_1G,
1325         .block_size_in_pages      = 64,
1326         .page_total_size_in_bytes = 4*SZ_1K + 128,
1327         .ecc_strength_in_bits     = 4,
1328         .ecc_size_in_bytes        = 512,
1329         .data_setup_in_ns         = 15,
1330         .data_hold_in_ns          = 10,
1331         .address_setup_in_ns      = 20,
1332         .gpmi_sample_delay_in_ns  = 6,
1333         .tREA_in_ns               = -1,
1334         .tRLOH_in_ns              = -1,
1335         .tRHOH_in_ns              = -1,
1336         NULL,
1337         },
1338         {
1339         .end_of_table             = false,
1340         .manufacturer_code        = 0xec,
1341         .device_code              = 0xd5,
1342         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
1343         .chip_size_in_bytes       = 2LL*SZ_1G,
1344         .block_size_in_pages      = 64,
1345         .page_total_size_in_bytes = 4*SZ_1K + 128,
1346         .ecc_strength_in_bits     = 4,
1347         .ecc_size_in_bytes        = 512,
1348         .data_setup_in_ns         = 25,
1349         .data_hold_in_ns          = 15,
1350         .address_setup_in_ns      = 30,
1351         .gpmi_sample_delay_in_ns  = 6,
1352         .tREA_in_ns               = -1,
1353         .tRLOH_in_ns              = -1,
1354         .tRHOH_in_ns              = -1,
1355         "K9NCG08U5M",
1356         },
1357         {
1358         .end_of_table             = false,
1359         .manufacturer_code        = 0xec,
1360         .device_code              = 0xd7,
1361         .cell_technology          = NAND_DEVICE_CELL_TECH_SLC,
1362         .chip_size_in_bytes       = 4LL*SZ_1G,
1363         .block_size_in_pages      = 64,
1364         .page_total_size_in_bytes = 4*SZ_1K + 128,
1365         .ecc_strength_in_bits     = 4,
1366         .ecc_size_in_bytes        = 512,
1367         .data_setup_in_ns         = 15,
1368         .data_hold_in_ns          = 15,
1369         .address_setup_in_ns      = 25,
1370         .gpmi_sample_delay_in_ns  = 6,
1371         .tREA_in_ns               = -1,
1372         .tRLOH_in_ns              = -1,
1373         .tRHOH_in_ns              = -1,
1374         NULL,
1375         },
1376         {true}
1377 };
1378
1379 /*
1380  * Type 11
1381  */
1382 static struct nand_device_info nand_device_info_table_type_11[] =
1383 {
1384         {
1385         .end_of_table             = false,
1386         .manufacturer_code        = 0x98,
1387         .device_code              = 0xd7,
1388         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1389         .chip_size_in_bytes       = 4LL*SZ_1G,
1390         .block_size_in_pages      = 128,
1391         .page_total_size_in_bytes = 8*SZ_1K + 376,
1392         .ecc_strength_in_bits     = 14,
1393         .ecc_size_in_bytes        = 512,
1394         .data_setup_in_ns         = 15,
1395         .data_hold_in_ns          = 10,
1396         .address_setup_in_ns      = 8,
1397         .gpmi_sample_delay_in_ns  = 6,
1398         .tREA_in_ns               = 20,
1399         .tRLOH_in_ns              = 5,
1400         .tRHOH_in_ns              = 25,
1401         "TC58NVG5D2ELAM8 (4GB), TH58NVG6D2ELAM8 (8GB)",
1402         },
1403         {
1404         .end_of_table             = false,
1405         .manufacturer_code        = 0x98,
1406         .device_code              = 0xde,
1407         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1408         .chip_size_in_bytes       = 8LL*SZ_1G,
1409         .block_size_in_pages      = 128,
1410         .page_total_size_in_bytes = 8*SZ_1K + 376,
1411         .ecc_strength_in_bits     = 14,
1412         .ecc_size_in_bytes        = 512,
1413         .data_setup_in_ns         = 15,
1414         .data_hold_in_ns          = 10,
1415         .address_setup_in_ns      = 8,
1416         .gpmi_sample_delay_in_ns  = 6,
1417         .tREA_in_ns               = 20,
1418         .tRLOH_in_ns              = 5,
1419         .tRHOH_in_ns              = 25,
1420         "TH58NVG7D2ELAM8",
1421         },
1422         {true}
1423 };
1424
1425 /*
1426  * Type 15
1427  */
1428 static struct nand_device_info nand_device_info_table_type_15[] =
1429 {
1430         {
1431         .end_of_table             = false,
1432         .manufacturer_code        = 0xec,
1433         .device_code              = 0xd7,
1434         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1435         .chip_size_in_bytes       = 4LL*SZ_1G,
1436         .block_size_in_pages      = 128,
1437         .page_total_size_in_bytes = 8*SZ_1K + 436,
1438         .ecc_strength_in_bits     = 16,
1439         .ecc_size_in_bytes        = 512,
1440         .data_setup_in_ns         = 20,
1441         .data_hold_in_ns          = 10,
1442         .address_setup_in_ns      = 25,
1443         .gpmi_sample_delay_in_ns  = 6,
1444         .tREA_in_ns               = 25,
1445         .tRLOH_in_ns              = 5,
1446         .tRHOH_in_ns              = 15,
1447         "K9GBG08U0M (4GB, 1CE); K9LCG08U1M (8GB, 2CE); K9HDG08U5M (16GB, 4CE)",
1448         },
1449         {true}
1450 };
1451
1452 /*
1453  * BCH ECC12
1454  */
1455 static struct nand_device_info nand_device_info_table_bch_ecc12[] =
1456 {
1457         {
1458         .end_of_table             = false,
1459         .manufacturer_code        = 0xad,
1460         .device_code              = 0xd7,
1461         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1462         .chip_size_in_bytes       = 4LL*SZ_1G,
1463         .block_size_in_pages      = 128,
1464         .page_total_size_in_bytes = 4*SZ_1K + 224,
1465         .ecc_strength_in_bits     = 12,
1466         .ecc_size_in_bytes        = 512,
1467         .data_setup_in_ns         = 15,
1468         .data_hold_in_ns          = 10,
1469         .address_setup_in_ns      = 20,
1470         .gpmi_sample_delay_in_ns  = 6,
1471         .tREA_in_ns               = 20,
1472         .tRLOH_in_ns              = 5,
1473         .tRHOH_in_ns              = 15,
1474         "H27UBG8T2M (4GB, 1CE), H27UCG8UDM (8GB, 2CE), H27UDG8VEM (16GB, 4CE)",
1475         },
1476         {
1477         .end_of_table             = false,
1478         .manufacturer_code        = 0xad,
1479         .device_code              = 0xde,
1480         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1481         .chip_size_in_bytes       = 8LL*SZ_1G,
1482         .block_size_in_pages      = 128,
1483         .page_total_size_in_bytes = 4*SZ_1K + 224,
1484         .ecc_strength_in_bits     = 12,
1485         .ecc_size_in_bytes        = 512,
1486         .data_setup_in_ns         = 15,
1487         .data_hold_in_ns          = 10,
1488         .address_setup_in_ns      = 20,
1489         .gpmi_sample_delay_in_ns  = 6,
1490         .tREA_in_ns               = 20,
1491         .tRLOH_in_ns              = 5,
1492         .tRHOH_in_ns              = 15,
1493         "H27UEG8YEM (32GB, 4CE)",
1494         },
1495         {
1496         .end_of_table             = false,
1497         .manufacturer_code        = 0x2c,
1498         .device_code              = 0xd7,
1499         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1500         .chip_size_in_bytes       = 4LL*SZ_1G,
1501         .block_size_in_pages      = 128,
1502         .page_total_size_in_bytes = 4*SZ_1K + 218,
1503         .ecc_strength_in_bits     = 12,
1504         .ecc_size_in_bytes        = 512,
1505         .data_setup_in_ns         = 10,
1506         .data_hold_in_ns          = 10,
1507         .address_setup_in_ns      = 15,
1508         .gpmi_sample_delay_in_ns  = 6,
1509         .tREA_in_ns               = 16,
1510         .tRLOH_in_ns              = 5,
1511         .tRHOH_in_ns              = 15,
1512         "MT29F32G08CBAAA (4GB, 1CE), MT29F64G08CFAAA (8GB, 2CE)",
1513         },
1514         {
1515         .end_of_table             = false,
1516         .manufacturer_code        = 0x2c,
1517         .device_code              = 0xd9,
1518         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1519         .chip_size_in_bytes       = 8LL*SZ_1G,
1520         .block_size_in_pages      = 128,
1521         .page_total_size_in_bytes = 4*SZ_1K + 218,
1522         .ecc_strength_in_bits     = 12,
1523         .ecc_size_in_bytes        = 512,
1524         .data_setup_in_ns         = 10,
1525         .data_hold_in_ns          = 10,
1526         .address_setup_in_ns      = 15,
1527         .gpmi_sample_delay_in_ns  = 6,
1528         .tREA_in_ns               = 16,
1529         .tRLOH_in_ns              = 5,
1530         .tRHOH_in_ns              = 15,
1531         "MT29F128G08CJAAA (16GB, 2CE)",
1532         },
1533         {
1534         .end_of_table             = false,
1535         .manufacturer_code        = 0x2c,
1536         .device_code              = 0x48,
1537         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1538         .chip_size_in_bytes       = 2LL*SZ_1G,
1539         .block_size_in_pages      = 256,
1540         .page_total_size_in_bytes = 4*SZ_1K + 224,
1541         .ecc_strength_in_bits     = 12,
1542         .ecc_size_in_bytes        = 512,
1543         .data_setup_in_ns         = 15,
1544         .data_hold_in_ns          = 10,
1545         .address_setup_in_ns      = 20,
1546         .gpmi_sample_delay_in_ns  = 6,
1547         .tREA_in_ns               = 20,
1548         .tRLOH_in_ns              = 5,
1549         .tRHOH_in_ns              = 15,
1550         "MT29F16G08CBABA (2GB, 1CE)",
1551         },
1552         {
1553         .end_of_table             = false,
1554         .manufacturer_code        = 0x2c,
1555         .device_code              = 0x68,
1556         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1557         .chip_size_in_bytes       = 4LL*SZ_1G,
1558         .block_size_in_pages      = 256,
1559         .page_total_size_in_bytes = 4*SZ_1K + 224,
1560         .ecc_strength_in_bits     = 12,
1561         .ecc_size_in_bytes        = 512,
1562         .data_setup_in_ns         = 15,
1563         .data_hold_in_ns          = 10,
1564         .address_setup_in_ns      = 20,
1565         .gpmi_sample_delay_in_ns  = 6,
1566         .tREA_in_ns               = 20,
1567         .tRLOH_in_ns              = 5,
1568         .tRHOH_in_ns              = 15,
1569         "MT29F32G08CBABA (4GB, 1CE); "
1570         "MT29F64G08CEABA (8GB, 2CE); "
1571         "MT29F64G08CFABA (8GB, 2CE)",
1572         },
1573         {
1574         .end_of_table             = false,
1575         .manufacturer_code        = 0x2c,
1576         .device_code              = 0x88,
1577         .cell_technology          = NAND_DEVICE_CELL_TECH_MLC,
1578         .chip_size_in_bytes       = 8LL*SZ_1G,
1579         .block_size_in_pages      = 256,
1580         .page_total_size_in_bytes = 4*SZ_1K + 224,
1581         .ecc_strength_in_bits     = 12,
1582         .ecc_size_in_bytes        = 512,
1583         .data_setup_in_ns         = 15,
1584         .data_hold_in_ns          = 10,
1585         .address_setup_in_ns      = 20,
1586         .gpmi_sample_delay_in_ns  = 6,
1587         .tREA_in_ns               = 20,
1588         .tRLOH_in_ns              = 5,
1589         .tRHOH_in_ns              = 15,
1590         "MT29F128G08CJABA (16GB, 2CE); "
1591         "MT29F128G08CKABA (16GB, 2CE); "
1592         "MT29F256G08CUABA (32GB, 4CE)",
1593         },
1594         {true}
1595 };
1596
1597 /*
1598  * The following macros make it convenient to extract information from an ID
1599  * byte array. All these macros begin with the prefix "ID_".
1600  *
1601  * Macros of the form:
1602  *
1603  *         ID_GET_[<manufacturer>_[<modifier>_]]<field>
1604  *
1605  * extract the given field from an ID byte array. Macros of the form:
1606  *
1607  *         ID_[<manufacturer>_[<modifier>_]]<field>_<meaning>
1608  *
1609  * contain the value for the given field that has the given meaning.
1610  *
1611  * If the <manufacturer> appears, it means this macro represents a view of this
1612  * field that is specific to the given manufacturer.
1613  *
1614  * If the <modifier> appears, it means this macro represents a view of this
1615  * field that the given manufacturer applies only under specific conditions.
1616  *
1617  * Here is a simple example:
1618  *
1619  *         ID_PAGE_SIZE_CODE_2K
1620  *
1621  * This macro has the value of the "Page Size" field that indicates the page
1622  * size is 2K.
1623  *
1624  * A more complicated example:
1625  *
1626  *         ID_SAMSUNG_6_BYTE_PAGE_SIZE_CODE_8K  (0x2)
1627  *
1628  * This macro has the value of the "Page Size" field for Samsung parts that
1629  * indicates the page size is 8K. However, this interpretation is only correct
1630  * for devices that return 6 ID bytes.
1631  */
1632
1633 /* Byte 1 ------------------------------------------------------------------- */
1634
1635 #define ID_GET_BYTE_1(id)    ((id)[0])
1636
1637 #define ID_GET_MFR_CODE(id)  ID_GET_BYTE_1(id)
1638
1639 /* Byte 2 ------------------------------------------------------------------- */
1640
1641 #define ID_GET_BYTE_2(id)                           ((id)[1])
1642
1643 #define ID_GET_DEVICE_CODE(id)                      ID_GET_BYTE_2(id)
1644     #define ID_SAMSUNG_DEVICE_CODE_1_GBIT           (0xf1)
1645     #define ID_SAMSUNG_DEVICE_CODE_2_GBIT           (0xda)
1646     #define ID_HYNIX_DEVICE_CODE_ECC12              (0xd7)
1647     #define ID_HYNIX_DEVICE_CODE_ECC12_LARGE        (0xde)
1648     #define ID_MICRON_DEVICE_CODE_ECC12             (0xd7) /* ECC12        */
1649     #define ID_MICRON_DEVICE_CODE_ECC12_LARGE       (0xd9) /* ECC12 8GB/CE */
1650     #define ID_MICRON_DEVICE_CODE_ECC12_2GB_PER_CE  (0x48) /* L63B  2GB/CE */
1651     #define ID_MICRON_DEVICE_CODE_ECC12_4GB_PER_CE  (0x68) /* L63B  4GB/CE */
1652     #define ID_MICRON_DEVICE_CODE_ECC12_8GB_PER_CE  (0x88) /* L63B  8GB/CE */
1653
1654 /* Byte 3 ------------------------------------------------------------------- */
1655
1656 #define ID_GET_BYTE_3(id)               ((id)[2])
1657
1658 #define ID_GET_DIE_COUNT_CODE(id)       ((ID_GET_BYTE_3(id) >> 0) & 0x3)
1659
1660 #define ID_GET_CELL_TYPE_CODE(id)       ((ID_GET_BYTE_3(id) >> 2) & 0x3)
1661     #define ID_CELL_TYPE_CODE_SLC       (0x0) /* All others => MLC. */
1662
1663 #define ID_GET_SAMSUNG_SIMUL_PROG(id)   ((ID_GET_BYTE_3(id) >> 4) & 0x3)
1664
1665 #define ID_GET_MICRON_SIMUL_PROG(id)    ((ID_GET_BYTE_3(id) >> 4) & 0x3)
1666
1667 #define ID_GET_CACHE_PROGRAM(id)        ((ID_GET_BYTE_3(id) >> 7) & 0x1)
1668
1669 /* Byte 4 ------------------------------------------------------------------- */
1670
1671 #define ID_GET_BYTE_4(id)                       ((id)[3])
1672     #define ID_HYNIX_BYTE_4_ECC12_DEVICE        (0x25)
1673
1674 #define ID_GET_PAGE_SIZE_CODE(id)               ((ID_GET_BYTE_4(id) >> 0) & 0x3)
1675     #define ID_PAGE_SIZE_CODE_1K                (0x0)
1676     #define ID_PAGE_SIZE_CODE_2K                (0x1)
1677     #define ID_PAGE_SIZE_CODE_4K                (0x2)
1678     #define ID_PAGE_SIZE_CODE_8K                (0x3)
1679     #define ID_SAMSUNG_6_BYTE_PAGE_SIZE_CODE_8K (0x2)
1680
1681 #define ID_GET_OOB_SIZE_CODE(id)                ((ID_GET_BYTE_4(id) >> 2) & 0x1)
1682
1683 #define ID_GET_BLOCK_SIZE_CODE(id)              ((ID_GET_BYTE_4(id) >> 4) & 0x3)
1684
1685 /* Byte 5 ------------------------------------------------------------------- */
1686
1687 #define ID_GET_BYTE_5(id)                  ((id)[4])
1688     #define ID_MICRON_BYTE_5_ECC12         (0x84)
1689
1690 #define ID_GET_SAMSUNG_ECC_LEVEL_CODE(id)  ((ID_GET_BYTE_5(id) >> 4) & 0x7)
1691     #define ID_SAMSUNG_ECC_LEVEL_CODE_8    (0x03)
1692     #define ID_SAMSUNG_ECC_LEVEL_CODE_24   (0x05)
1693
1694 #define ID_GET_PLANE_COUNT_CODE(id)        ((ID_GET_BYTE_5(id) >> 2) & 0x3)
1695
1696 /* Byte 6 ------------------------------------------------------------------- */
1697
1698 #define ID_GET_BYTE_6(id)                        ((id)[5])
1699     #define ID_TOSHIBA_BYTE_6_PAGE_SIZE_CODE_8K  (0x54)
1700     #define ID_TOSHIBA_BYTE_6_PAGE_SIZE_CODE_4K  (0x13)
1701
1702 #define ID_GET_SAMSUNG_DEVICE_VERSION_CODE(id)   ((ID_GET_BYTE_6(id)>>0) & 0x7)
1703     #define ID_SAMSUNG_DEVICE_VERSION_CODE_40NM  (0x01)
1704
1705 /* -------------------------------------------------------------------------- */
1706
1707 void nand_device_print_info(struct nand_device_info *info)
1708 {
1709         unsigned    i;
1710         const char  *mfr_name;
1711         const char  *cell_technology_name;
1712         uint64_t    chip_size;
1713         const char  *chip_size_units;
1714         unsigned    page_data_size_in_bytes;
1715         unsigned    page_oob_size_in_bytes;
1716
1717         /* Check for nonsense. */
1718
1719         if (!info)
1720                 return;
1721
1722         /* Prepare the manufacturer name. */
1723
1724         mfr_name = "Unknown";
1725
1726         for (i = 0; nand_manuf_ids[i].id; i++) {
1727                 if (nand_manuf_ids[i].id == info->manufacturer_code) {
1728                         mfr_name = nand_manuf_ids[i].name;
1729                         break;
1730                 }
1731         }
1732
1733         /* Prepare the name of the cell technology. */
1734
1735         switch (info->cell_technology) {
1736         case NAND_DEVICE_CELL_TECH_SLC:
1737                 cell_technology_name = "SLC";
1738                 break;
1739         case NAND_DEVICE_CELL_TECH_MLC:
1740                 cell_technology_name = "MLC";
1741                 break;
1742         default:
1743                 cell_technology_name = "Unknown";
1744                 break;
1745         }
1746
1747         /* Prepare the chip size. */
1748
1749         if ((info->chip_size_in_bytes >= SZ_1G) &&
1750                                         !(info->chip_size_in_bytes % SZ_1G)) {
1751                 chip_size       = info->chip_size_in_bytes / ((uint64_t) SZ_1G);
1752                 chip_size_units = "GiB";
1753         } else if ((info->chip_size_in_bytes >= SZ_1M) &&
1754                                         !(info->chip_size_in_bytes % SZ_1M)) {
1755                 chip_size       = info->chip_size_in_bytes / ((uint64_t) SZ_1M);
1756                 chip_size_units = "MiB";
1757         } else {
1758                 chip_size       = info->chip_size_in_bytes;
1759                 chip_size_units = "B";
1760         }
1761
1762         /* Prepare the page geometry. */
1763
1764         page_data_size_in_bytes = info->page_total_size_in_bytes & ~0x3ff;
1765         page_oob_size_in_bytes  = info->page_total_size_in_bytes & 0x3ff;
1766
1767         /* Print the information. */
1768
1769         printk(KERN_INFO "Manufacturer      : %s (0x%02x)\n",  mfr_name,
1770                                                 info->manufacturer_code);
1771         printk(KERN_INFO "Device Code       : 0x%02x\n", info->device_code);
1772         printk(KERN_INFO "Cell Technology   : %s\n", cell_technology_name);
1773         printk(KERN_INFO "Chip Size         : %u %s\n", (u32)chip_size,
1774                                                         chip_size_units);
1775         printk(KERN_INFO "Pages per Block   : %u\n",
1776                                                 info->block_size_in_pages);
1777         printk(KERN_INFO "Page Geometry     : %u+%u\n", page_data_size_in_bytes,
1778                                                 page_oob_size_in_bytes);
1779         printk(KERN_INFO "ECC Strength      : %u bits\n",
1780                                                 info->ecc_strength_in_bits);
1781         printk(KERN_INFO "ECC Size          : %u B\n", info->ecc_size_in_bytes);
1782         printk(KERN_INFO "Data Setup Time   : %u ns\n", info->data_setup_in_ns);
1783         printk(KERN_INFO "Data Hold Time    : %u ns\n", info->data_hold_in_ns);
1784         printk(KERN_INFO "Address Setup Time: %u ns\n",
1785                                                 info->address_setup_in_ns);
1786         printk(KERN_INFO "GPMI Sample Delay : %u ns\n",
1787                                                 info->gpmi_sample_delay_in_ns);
1788         if (info->tREA_in_ns >= 0)
1789                 printk(KERN_INFO "tREA              : %u ns\n",
1790                                                         info->tREA_in_ns);
1791         else
1792                 printk(KERN_INFO "tREA              : Unknown\n");
1793         if (info->tREA_in_ns >= 0)
1794                 printk(KERN_INFO "tRLOH             : %u ns\n",
1795                                                         info->tRLOH_in_ns);
1796         else
1797                 printk(KERN_INFO "tRLOH             : Unknown\n");
1798         if (info->tREA_in_ns >= 0)
1799                 printk(KERN_INFO "tRHOH             : %u ns\n",
1800                                                         info->tRHOH_in_ns);
1801         else
1802                 printk(KERN_INFO "tRHOH             : Unknown\n");
1803         if (info->description)
1804                 printk(KERN_INFO "Description       : %s\n", info->description);
1805         else
1806                 printk(KERN_INFO "Description       : <None>\n");
1807
1808 }
1809
1810 static struct nand_device_info *nand_device_info_search(
1811         struct nand_device_info *table, uint8_t mfr_code, uint8_t device_code)
1812 {
1813
1814         for (; !table->end_of_table; table++) {
1815                 if (table->manufacturer_code != mfr_code)
1816                         continue;
1817                 if (table->device_code != device_code)
1818                         continue;
1819                 return table;
1820         }
1821
1822         return 0;
1823
1824 }
1825
1826 static struct nand_device_info *nand_device_info_fn_toshiba(const uint8_t id[])
1827 {
1828         struct nand_device_info  *table;
1829
1830         /* Check for an SLC device. */
1831
1832         if (ID_GET_CELL_TYPE_CODE(id) == ID_CELL_TYPE_CODE_SLC) {
1833                 /* Type 2 */
1834                 return nand_device_info_search(nand_device_info_table_type_2,
1835                                 ID_GET_MFR_CODE(id), ID_GET_DEVICE_CODE(id));
1836         }
1837
1838         /*
1839          * Look for 8K page Toshiba MLC devices.
1840          *
1841          * The page size field in byte 4 can't be used because the field was
1842          * redefined in the 8K parts so the value meaning "8K page" is the same
1843          * as the value meaning "4K page" on the 4K page devices.
1844          *
1845          * The only identifiable difference between the 4K and 8K page Toshiba
1846          * devices with a device code of 0xd7 is the undocumented 6th ID byte.
1847          * The 4K device returns a value of 0x13 and the 8K a value of 0x54.
1848          * Toshiba has verified that this is an acceptable method to distinguish
1849          * the two device families.
1850          */
1851
1852         if (ID_GET_BYTE_6(id) == ID_TOSHIBA_BYTE_6_PAGE_SIZE_CODE_8K) {
1853                 /* Type 11 */
1854                 table = nand_device_info_table_type_11;
1855         } else if (ID_GET_PAGE_SIZE_CODE(id) == ID_PAGE_SIZE_CODE_4K) {
1856                 /* Type 9 */
1857                 table = nand_device_info_table_type_9;
1858         } else {
1859                 /* Large MLC */
1860                 table = nand_device_info_table_large_mlc;
1861         }
1862
1863         return nand_device_info_search(table, ID_GET_MFR_CODE(id),
1864                                                         ID_GET_DEVICE_CODE(id));
1865
1866 }
1867
1868 static struct nand_device_info *nand_device_info_fn_samsung(const uint8_t id[])
1869 {
1870         struct nand_device_info  *table;
1871
1872         /* Check for an MLC device. */
1873
1874         if (ID_GET_CELL_TYPE_CODE(id) != ID_CELL_TYPE_CODE_SLC) {
1875
1876                 /* Is this a Samsung 8K Page MLC device with 16 bit ECC? */
1877                 if ((ID_GET_SAMSUNG_ECC_LEVEL_CODE(id) ==
1878                                         ID_SAMSUNG_ECC_LEVEL_CODE_24) &&
1879                     (ID_GET_PAGE_SIZE_CODE(id) ==
1880                                         ID_SAMSUNG_6_BYTE_PAGE_SIZE_CODE_8K)) {
1881                         /* Type 15 */
1882                         table = nand_device_info_table_type_15;
1883                 }
1884                 /* Is this a Samsung 42nm ECC8 device with a 6 byte ID? */
1885                 else if ((ID_GET_SAMSUNG_ECC_LEVEL_CODE(id) ==
1886                                         ID_SAMSUNG_ECC_LEVEL_CODE_8) &&
1887                         (ID_GET_SAMSUNG_DEVICE_VERSION_CODE(id) ==
1888                                         ID_SAMSUNG_DEVICE_VERSION_CODE_40NM)) {
1889                         /* Type 9 */
1890                         table = nand_device_info_table_type_9;
1891                 } else if (ID_GET_PAGE_SIZE_CODE(id) == ID_PAGE_SIZE_CODE_4K) {
1892                         /* Type 8 */
1893                         table = nand_device_info_table_type_8;
1894                 } else {
1895                         /* Large MLC */
1896                         table = nand_device_info_table_large_mlc;
1897                 }
1898
1899         } else {
1900
1901                 /* Check the page size first. */
1902                 if (ID_GET_PAGE_SIZE_CODE(id) == ID_PAGE_SIZE_CODE_4K) {
1903                         /* Type 10 */
1904                         table = nand_device_info_table_type_10;
1905                 }
1906                 /* Check the chip size. */
1907                 else if (ID_GET_DEVICE_CODE(id) ==
1908                                                 ID_SAMSUNG_DEVICE_CODE_1_GBIT) {
1909                         if (!ID_GET_CACHE_PROGRAM(id)) {
1910                                 /*
1911                                  * 128 MiB Samsung chips without cache program
1912                                  * are Type 7.
1913                                  *
1914                                  * The K9F1G08U0B does not support multi-plane
1915                                  * program, so the if statement below cannot be
1916                                  * used to identify it.
1917                                  */
1918                                 table = nand_device_info_table_type_7;
1919
1920                         } else {
1921                                 /* Smaller sizes are Type 2 by default. */
1922                                 table = nand_device_info_table_type_2;
1923                         }
1924                 } else {
1925                         /* Check number of simultaneously programmed pages. */
1926                         if (ID_GET_SAMSUNG_SIMUL_PROG(id) &&
1927                                                 ID_GET_PLANE_COUNT_CODE(id)) {
1928                                 /* Type 7 */
1929                                 table = nand_device_info_table_type_7;
1930                         } else {
1931                                 /* Type 2 */
1932                                 table = nand_device_info_table_type_2;
1933                         }
1934
1935                 }
1936
1937         }
1938
1939         return nand_device_info_search(table, ID_GET_MFR_CODE(id),
1940                                                         ID_GET_DEVICE_CODE(id));
1941
1942 }
1943
1944 static struct nand_device_info *nand_device_info_fn_stmicro(const uint8_t id[])
1945 {
1946         struct nand_device_info  *table;
1947
1948         /* Check for an SLC device. */
1949
1950         if (ID_GET_CELL_TYPE_CODE(id) == ID_CELL_TYPE_CODE_SLC)
1951                 /* Type 2 */
1952                 table = nand_device_info_table_type_2;
1953         else
1954                 /* Large MLC */
1955                 table = nand_device_info_table_large_mlc;
1956
1957         return nand_device_info_search(table, ID_GET_MFR_CODE(id),
1958                                                         ID_GET_DEVICE_CODE(id));
1959
1960 }
1961
1962 static struct nand_device_info *nand_device_info_fn_hynix(const uint8_t id[])
1963 {
1964         struct nand_device_info  *table;
1965
1966         /* Check for an SLC device. */
1967
1968         if (ID_GET_CELL_TYPE_CODE(id) == ID_CELL_TYPE_CODE_SLC) {
1969                 /* Type 2 */
1970                 return nand_device_info_search(nand_device_info_table_type_2,
1971                                 ID_GET_MFR_CODE(id), ID_GET_DEVICE_CODE(id));
1972         }
1973
1974         /*
1975          * Check for ECC12 devices.
1976          *
1977          * We look at the 4th ID byte to distinguish some Hynix ECC12 devices
1978          * from the similar ECC8 part. For example H27UBG8T2M (ECC12) 4th byte
1979          * is 0x25, whereas H27UDG8WFM (ECC8) 4th byte is 0xB6.
1980          */
1981
1982         if ((ID_GET_DEVICE_CODE(id) == ID_HYNIX_DEVICE_CODE_ECC12 &&
1983                         ID_GET_BYTE_4(id) == ID_HYNIX_BYTE_4_ECC12_DEVICE) ||
1984             (ID_GET_DEVICE_CODE(id) == ID_HYNIX_DEVICE_CODE_ECC12_LARGE)) {
1985                 /* BCH ECC 12 */
1986                 table = nand_device_info_table_bch_ecc12;
1987         } else if (ID_GET_PAGE_SIZE_CODE(id) == ID_PAGE_SIZE_CODE_4K) {
1988                 /*
1989                  * So far, all other Samsung and Hynix 4K page devices are
1990                  * Type 8.
1991                  */
1992                 table = nand_device_info_table_type_8;
1993         } else
1994                 /* Large MLC */
1995                 table = nand_device_info_table_large_mlc;
1996
1997         return nand_device_info_search(table, ID_GET_MFR_CODE(id),
1998                                                         ID_GET_DEVICE_CODE(id));
1999
2000 }
2001
2002 static struct nand_device_info *nand_device_info_fn_micron(const uint8_t id[])
2003 {
2004         struct nand_device_info  *table;
2005
2006         /* Check for an SLC device. */
2007
2008         if (ID_GET_CELL_TYPE_CODE(id) == ID_CELL_TYPE_CODE_SLC) {
2009
2010                 /* Check number of simultaneously programmed pages. */
2011
2012                 if (ID_GET_MICRON_SIMUL_PROG(id)) {
2013                         /* Type 7 */
2014                         table = nand_device_info_table_type_7;
2015                 } else {
2016                         /* Zero simultaneously programmed pages means Type 2. */
2017                         table = nand_device_info_table_type_2;
2018                 }
2019
2020                 return nand_device_info_search(table, ID_GET_MFR_CODE(id),
2021                                                         ID_GET_DEVICE_CODE(id));
2022
2023         }
2024
2025         /*
2026          * We look at the 5th ID byte to distinguish some Micron ECC12 NANDs
2027          * from the similar ECC8 part.
2028          *
2029          * For example MT29F64G08CFAAA (ECC12) 5th byte is 0x84, whereas
2030          * MT29F64G08TAA (ECC8) 5th byte is 0x78.
2031          *
2032          * We also have a special case for the Micron L63B family
2033          * (256 page/block), which has unique device codes but no ID fields that
2034          * can easily be used to distinguish the family.
2035          */
2036
2037         if ((ID_GET_DEVICE_CODE(id) == ID_MICRON_DEVICE_CODE_ECC12 &&
2038                                 ID_GET_BYTE_5(id) == ID_MICRON_BYTE_5_ECC12)  ||
2039            (ID_GET_DEVICE_CODE(id) == ID_MICRON_DEVICE_CODE_ECC12_LARGE)      ||
2040            (ID_GET_DEVICE_CODE(id) == ID_MICRON_DEVICE_CODE_ECC12_2GB_PER_CE) ||
2041            (ID_GET_DEVICE_CODE(id) == ID_MICRON_DEVICE_CODE_ECC12_4GB_PER_CE) ||
2042            (ID_GET_DEVICE_CODE(id) == ID_MICRON_DEVICE_CODE_ECC12_8GB_PER_CE)) {
2043                 /* BCH ECC 12 */
2044                 table = nand_device_info_table_bch_ecc12;
2045         } else if (ID_GET_PAGE_SIZE_CODE(id) == ID_PAGE_SIZE_CODE_4K) {
2046                 /* Toshiba devices with 4K pages are Type 9. */
2047                 table = nand_device_info_table_type_9;
2048         } else {
2049                 /* Large MLC */
2050                 table = nand_device_info_table_large_mlc;
2051         }
2052
2053         return nand_device_info_search(table, ID_GET_MFR_CODE(id),
2054                                                         ID_GET_DEVICE_CODE(id));
2055
2056 }
2057
2058 static struct nand_device_info *nand_device_info_fn_sandisk(const uint8_t id[])
2059 {
2060         struct nand_device_info  *table;
2061
2062         if (ID_GET_CELL_TYPE_CODE(id) != ID_CELL_TYPE_CODE_SLC) {
2063                 /* Large MLC */
2064                 table = nand_device_info_table_large_mlc;
2065         } else {
2066                 /* Type 2 */
2067                 table = nand_device_info_table_type_2;
2068         }
2069
2070         return nand_device_info_search(table, ID_GET_MFR_CODE(id),
2071                                                         ID_GET_DEVICE_CODE(id));
2072
2073 }
2074
2075 static struct nand_device_info *nand_device_info_fn_intel(const uint8_t id[])
2076 {
2077         struct nand_device_info  *table;
2078
2079         /* Check for an SLC device. */
2080
2081         if (ID_GET_CELL_TYPE_CODE(id) == ID_CELL_TYPE_CODE_SLC) {
2082                 /* Type 2 */
2083                 return nand_device_info_search(nand_device_info_table_type_2,
2084                                 ID_GET_MFR_CODE(id), ID_GET_DEVICE_CODE(id));
2085         }
2086
2087         if (ID_GET_PAGE_SIZE_CODE(id) == ID_PAGE_SIZE_CODE_4K) {
2088                 /* Type 9 */
2089                 table = nand_device_info_table_type_9;
2090         } else {
2091                 /* Large MLC */
2092                 table = nand_device_info_table_large_mlc;
2093         }
2094
2095         return nand_device_info_search(table, ID_GET_MFR_CODE(id),
2096                                                         ID_GET_DEVICE_CODE(id));
2097
2098 }
2099
2100 /**
2101  * struct nand_device_type_info - Information about a NAND Flash type.
2102  *
2103  * @name:   A human-readable name for this type.
2104  * @table:  The device info table for this type.
2105  */
2106
2107 struct nand_device_type_info {
2108         struct nand_device_info  *table;
2109         const char               *name;
2110 };
2111
2112 /*
2113  * A table that maps manufacturer IDs to device information tables.
2114  */
2115
2116 static struct nand_device_type_info  nand_device_type_directory[] =
2117 {
2118         {nand_device_info_table_type_2,    "Type 2"   },
2119         {nand_device_info_table_large_mlc, "Large MLC"},
2120         {nand_device_info_table_type_7,    "Type 7"   },
2121         {nand_device_info_table_type_8,    "Type 8"   },
2122         {nand_device_info_table_type_9,    "Type 9"   },
2123         {nand_device_info_table_type_10,   "Type 10"  },
2124         {nand_device_info_table_type_11,   "Type 11"  },
2125         {nand_device_info_table_type_15,   "Type 15"  },
2126         {nand_device_info_table_bch_ecc12, "BCH ECC12"},
2127         {0, 0},
2128 };
2129
2130 /**
2131  * struct nand_device_mfr_info - Information about a NAND Flash manufacturer.
2132  *
2133  * @id:     The value of the first NAND Flash ID byte, which identifies the
2134  *          manufacturer.
2135  * @fn:     A pointer to a function to use for identifying devices from the
2136  *          given manufacturer.
2137  */
2138
2139 struct nand_device_mfr_info {
2140         uint8_t                  id;
2141         struct nand_device_info  *(*fn)(const uint8_t id[]);
2142 };
2143
2144 /*
2145  * A table that maps manufacturer IDs to device information tables.
2146  */
2147
2148 static struct nand_device_mfr_info  nand_device_mfr_directory[] =
2149 {
2150         {
2151         .id = NAND_MFR_TOSHIBA,
2152         .fn = nand_device_info_fn_toshiba,
2153         },
2154         {
2155         .id = NAND_MFR_SAMSUNG,
2156         .fn = nand_device_info_fn_samsung,
2157         },
2158         {
2159         .id = NAND_MFR_FUJITSU,
2160         .fn = 0,
2161         },
2162         {
2163         .id = NAND_MFR_NATIONAL,
2164         .fn = 0,
2165         },
2166         {
2167         .id = NAND_MFR_RENESAS,
2168         .fn = 0,
2169         },
2170         {
2171         .id = NAND_MFR_STMICRO,
2172         .fn = nand_device_info_fn_stmicro,
2173         },
2174         {
2175         .id = NAND_MFR_HYNIX,
2176         .fn = nand_device_info_fn_hynix,
2177         },
2178         {
2179         .id = NAND_MFR_MICRON,
2180         .fn = nand_device_info_fn_micron,
2181         },
2182         {
2183         .id = NAND_MFR_AMD,
2184         .fn = 0,
2185         },
2186         {
2187         .id = NAND_MFR_SANDISK,
2188         .fn = nand_device_info_fn_sandisk,
2189         },
2190         {
2191         .id = NAND_MFR_INTEL,
2192         .fn = nand_device_info_fn_intel,
2193         },
2194         {0, 0}
2195 };
2196
2197 /**
2198  * nand_device_info_test_table - Validate a device info table.
2199  *
2200  * This function runs tests on the given device info table to check that it
2201  * meets the current assumptions.
2202  */
2203
2204 static void nand_device_info_test_table(
2205                         struct nand_device_info *table, const char * name)
2206 {
2207         unsigned  i;
2208         unsigned  j;
2209         uint8_t   mfr_code;
2210         uint8_t   device_code;
2211
2212         /* Loop over entries in this table. */
2213
2214         for (i = 0; !table[i].end_of_table; i++) {
2215
2216                 /* Get discriminating attributes of the current device. */
2217
2218                 mfr_code    = table[i].manufacturer_code;
2219                 device_code = table[i].device_code;
2220
2221                 /* Compare with the remaining devices in this table. */
2222
2223                 for (j = i + 1; !table[j].end_of_table; j++) {
2224                         if ((mfr_code    == table[j].manufacturer_code) &&
2225                             (device_code == table[j].device_code))
2226                                 goto error;
2227                 }
2228
2229         }
2230
2231         return;
2232
2233 error:
2234
2235         printk(KERN_EMERG
2236                 "\n== NAND Flash device info table failed validity check ==\n");
2237
2238         printk(KERN_EMERG "\nDevice Info Table: %s\n", name);
2239         printk(KERN_EMERG "\nTable Index %u\n", i);
2240         nand_device_print_info(table + i);
2241         printk(KERN_EMERG "\nTable Index %u\n", j);
2242         nand_device_print_info(table + j);
2243         printk(KERN_EMERG "\n");
2244
2245         BUG();
2246
2247 }
2248
2249 /**
2250  * nand_device_info_test_data - Test the NAND Flash device data.
2251  */
2252
2253 static void nand_device_info_test_data(void)
2254 {
2255
2256         unsigned  i;
2257
2258         for (i = 0; nand_device_type_directory[i].name; i++) {
2259                 nand_device_info_test_table(
2260                                         nand_device_type_directory[i].table,
2261                                         nand_device_type_directory[i].name);
2262         }
2263
2264 }
2265
2266 struct nand_device_info *nand_device_get_info(const uint8_t id[])
2267 {
2268         unsigned                 i;
2269         uint8_t                  mfr_id = ID_GET_MFR_CODE(id);
2270         struct nand_device_info  *(*fn)(const uint8_t id[]) = 0;
2271
2272         /* Test the data. */
2273
2274         nand_device_info_test_data();
2275
2276         /* Look for information about this manufacturer. */
2277
2278         for (i = 0; nand_device_mfr_directory[i].id; i++) {
2279                 if (nand_device_mfr_directory[i].id == mfr_id) {
2280                         fn = nand_device_mfr_directory[i].fn;
2281                         break;
2282                 }
2283         }
2284
2285         if (!fn)
2286                 return 0;
2287
2288         /*
2289          * If control arrives here, we found both a table of device information,
2290          * and a function we can use to identify the current device. Attempt to
2291          * identify the device and return the result.
2292          */
2293
2294         return fn(id);
2295
2296 }