2008-07-15 17:17:01 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 by Maurus Cuelenaere
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "nand_id.h"
|
|
|
|
|
|
|
|
struct nand_manufacturer
|
|
|
|
{
|
2009-01-22 00:04:20 +00:00
|
|
|
unsigned char id;
|
|
|
|
struct nand_info* info;
|
2008-07-15 17:17:01 +00:00
|
|
|
unsigned short total;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct nand_info samsung[] =
|
|
|
|
{
|
2009-01-22 00:04:20 +00:00
|
|
|
/* { id1, id2, pages_per_block, blocks_per_bank, page_size, spare_size, col_cycles, row_cycles } */
|
|
|
|
|
|
|
|
/* K9F4G08UOM */
|
|
|
|
{0xDC, 0x10, 64, 4096, 2048, 64, 2, 3 },
|
|
|
|
/* K9K8G08UOM */
|
|
|
|
{0xD3, 0x51, 64, 8192, 2048, 64, 2, 3 },
|
|
|
|
/* K9LAG08UOM */
|
|
|
|
{0xD5, 0x55, 128, 8192, 2048, 64, 2, 3 },
|
|
|
|
/* K9LBG08UOM, K9HBG08U1M, K9MCG08U5M */
|
|
|
|
{0xD7, 0x55, 128, 8192, 4096, 128, 2, 3 },
|
2008-07-15 17:17:01 +00:00
|
|
|
};
|
|
|
|
|
2009-01-22 00:04:20 +00:00
|
|
|
#define NI(id, x) {id, (struct nand_info*)x, (sizeof(x)/sizeof(struct nand_info))}
|
2008-07-15 17:17:01 +00:00
|
|
|
static const struct nand_manufacturer all[] =
|
|
|
|
{
|
2009-01-22 00:04:20 +00:00
|
|
|
NI(0xEC, samsung),
|
2008-07-15 17:17:01 +00:00
|
|
|
};
|
|
|
|
|
2009-01-22 00:04:20 +00:00
|
|
|
// --------------------------------------------------------------------------------------------------
|
|
|
|
|
2008-07-15 17:17:01 +00:00
|
|
|
struct nand_info* nand_identify(unsigned char data[5])
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
int found = -1;
|
2009-01-22 00:04:20 +00:00
|
|
|
|
2008-07-15 17:17:01 +00:00
|
|
|
for(i = 0; i < (sizeof(all)/sizeof(struct nand_manufacturer)); i++)
|
|
|
|
{
|
|
|
|
if(data[0] == all[i].id)
|
|
|
|
{
|
|
|
|
found = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-01-22 00:04:20 +00:00
|
|
|
|
2008-07-15 17:17:01 +00:00
|
|
|
if(found < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for(i = 0; i < all[found].total; i++)
|
|
|
|
{
|
|
|
|
if(data[1] == all[found].info[i].dev_id &&
|
|
|
|
data[2] == all[found].info[i].dev_id2)
|
|
|
|
return &all[found].info[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|