summaryrefslogtreecommitdiff
path: root/firmware/drivers/nand_id.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/nand_id.c')
-rw-r--r--firmware/drivers/nand_id.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/firmware/drivers/nand_id.c b/firmware/drivers/nand_id.c
new file mode 100644
index 0000000000..ab10ecec07
--- /dev/null
+++ b/firmware/drivers/nand_id.c
@@ -0,0 +1,73 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdlib.h>
23#include "nand_id.h"
24
25struct nand_manufacturer
26{
27 unsigned char id;
28 struct nand_info* info;
29 unsigned short total;
30};
31
32/* { pages_per_block, blocks_per_bank, page_size, spare_size, col_cycles, row_cycles } */
33
34static const struct nand_info samsung[] =
35{
36 /* K9K8G08UOM */
37 {0xD3, 0x51, 64, 8192, 2048, 64, 2, 3},
38 /* K9LAG08UOM */
39 {0xD5, 0x55, 128, 8192, 2048, 64, 2, 3},
40 /* K9LBG08UOM, K9HBG08U1M, K9MCG08U5M */
41 {0xD7, 0x55, 128, 8192, 4096, 128, 2, 3},
42};
43
44#define M(id, x) {id, (struct nand_info*)x, (sizeof(x)/sizeof(struct nand_info))}
45static const struct nand_manufacturer all[] =
46{
47 M(0xEC, samsung),
48};
49
50struct nand_info* nand_identify(unsigned char data[5])
51 {
52 unsigned int i;
53 int found = -1;
54 for(i = 0; i < (sizeof(all)/sizeof(struct nand_manufacturer)); i++)
55 {
56 if(data[0] == all[i].id)
57 {
58 found = i;
59 break;
60 }
61 }
62 if(found < 0)
63 return NULL;
64
65 for(i = 0; i < all[found].total; i++)
66 {
67 if(data[1] == all[found].info[i].dev_id &&
68 data[2] == all[found].info[i].dev_id2)
69 return &all[found].info[i];
70 }
71
72 return NULL;
73}