mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-07-07 03:36:16 +09:00
sf: stmicro: support JEDEC standard two-byte signature
There are more than the M25Pxx serial flashs that can be used with the stmicro driver, for example: the M25PXxx or N25Qxx serie. All these chips have burned in the original stmicro manufacture id 0x20 together with a standard two-byte signature. In preperation to support all these chips the stmicro driver have to decode the full two-byte signature. Signed-off-by: Stephan Linz <linz@li-pro.net> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
c969abc470
commit
63ff6a66ae
|
@ -37,7 +37,7 @@
|
||||||
#define CMD_M25PXX_RES 0xab /* Release from DP, and Read Signature */
|
#define CMD_M25PXX_RES 0xab /* Release from DP, and Read Signature */
|
||||||
|
|
||||||
struct stmicro_spi_flash_params {
|
struct stmicro_spi_flash_params {
|
||||||
u8 idcode1;
|
u16 id;
|
||||||
u16 pages_per_sector;
|
u16 pages_per_sector;
|
||||||
u16 nr_sectors;
|
u16 nr_sectors;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -45,55 +45,55 @@ struct stmicro_spi_flash_params {
|
||||||
|
|
||||||
static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
|
static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
|
||||||
{
|
{
|
||||||
.idcode1 = 0x11,
|
.id = 0x2011,
|
||||||
.pages_per_sector = 128,
|
.pages_per_sector = 128,
|
||||||
.nr_sectors = 4,
|
.nr_sectors = 4,
|
||||||
.name = "M25P10",
|
.name = "M25P10",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x15,
|
.id = 0x2015,
|
||||||
.pages_per_sector = 256,
|
.pages_per_sector = 256,
|
||||||
.nr_sectors = 32,
|
.nr_sectors = 32,
|
||||||
.name = "M25P16",
|
.name = "M25P16",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x12,
|
.id = 0x2012,
|
||||||
.pages_per_sector = 256,
|
.pages_per_sector = 256,
|
||||||
.nr_sectors = 4,
|
.nr_sectors = 4,
|
||||||
.name = "M25P20",
|
.name = "M25P20",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x16,
|
.id = 0x2016,
|
||||||
.pages_per_sector = 256,
|
.pages_per_sector = 256,
|
||||||
.nr_sectors = 64,
|
.nr_sectors = 64,
|
||||||
.name = "M25P32",
|
.name = "M25P32",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x13,
|
.id = 0x2013,
|
||||||
.pages_per_sector = 256,
|
.pages_per_sector = 256,
|
||||||
.nr_sectors = 8,
|
.nr_sectors = 8,
|
||||||
.name = "M25P40",
|
.name = "M25P40",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x17,
|
.id = 0x2017,
|
||||||
.pages_per_sector = 256,
|
.pages_per_sector = 256,
|
||||||
.nr_sectors = 128,
|
.nr_sectors = 128,
|
||||||
.name = "M25P64",
|
.name = "M25P64",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x14,
|
.id = 0x2014,
|
||||||
.pages_per_sector = 256,
|
.pages_per_sector = 256,
|
||||||
.nr_sectors = 16,
|
.nr_sectors = 16,
|
||||||
.name = "M25P80",
|
.name = "M25P80",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x18,
|
.id = 0x2018,
|
||||||
.pages_per_sector = 1024,
|
.pages_per_sector = 1024,
|
||||||
.nr_sectors = 64,
|
.nr_sectors = 64,
|
||||||
.name = "M25P128",
|
.name = "M25P128",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.idcode1 = 0x19,
|
.id = 0xba19,
|
||||||
.pages_per_sector = 256,
|
.pages_per_sector = 256,
|
||||||
.nr_sectors = 512,
|
.nr_sectors = 512,
|
||||||
.name = "N25Q256",
|
.name = "N25Q256",
|
||||||
|
@ -105,6 +105,7 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
|
||||||
const struct stmicro_spi_flash_params *params;
|
const struct stmicro_spi_flash_params *params;
|
||||||
struct spi_flash *flash;
|
struct spi_flash *flash;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
u16 id;
|
||||||
|
|
||||||
if (idcode[0] == 0xff) {
|
if (idcode[0] == 0xff) {
|
||||||
i = spi_flash_cmd(spi, CMD_M25PXX_RES,
|
i = spi_flash_cmd(spi, CMD_M25PXX_RES,
|
||||||
|
@ -119,15 +120,17 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id = ((idcode[1] << 8) | idcode[2]);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) {
|
for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) {
|
||||||
params = &stmicro_spi_flash_table[i];
|
params = &stmicro_spi_flash_table[i];
|
||||||
if (params->idcode1 == idcode[2]) {
|
if (params->id == id) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == ARRAY_SIZE(stmicro_spi_flash_table)) {
|
if (i == ARRAY_SIZE(stmicro_spi_flash_table)) {
|
||||||
debug("SF: Unsupported STMicro ID %02x\n", idcode[1]);
|
debug("SF: Unsupported STMicro ID %04x\n", id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user