From c49e9e496286cf16eda4910dbb95dc48660b7751 Mon Sep 17 00:00:00 2001 From: Jagannadha Sutradharudu Teki Date: Sat, 25 Aug 2012 23:28:06 +0530 Subject: [PATCH] Xilinx: ARM: sf: stmicro: Support for numonyx ID table This patch resolved the conflict between Numonyx and Micron based flash devices. Added two bytes instead of one byte for full device ID detection through idcode member. Now JEDEC standard two-byte signature is used for id detection. Signed-off-by: Jagannadha Sutradharudu Teki --- drivers/mtd/spi/stmicro.c | 48 ++++++++++++--------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c index 31fb42329d0..9c85620d7f1 100644 --- a/drivers/mtd/spi/stmicro.c +++ b/drivers/mtd/spi/stmicro.c @@ -47,10 +47,7 @@ #define CMD_M25PXX_RES 0xab /* Release from DP, and Read Signature */ struct stmicro_spi_flash_params { - u8 idcode1; - /* XILINX: idcode1 isn't specific enough; - * multiple non-compatible devices match. Store complete idcode */ - u32 idcode; + u16 idcode1; u16 page_size; u16 pages_per_sector; u16 nr_sectors; @@ -107,36 +104,27 @@ static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = { .nr_sectors = 16, .name = "M25P80", }, -/* - * XILINX: - * This table only examines the capacity of the device. - * The M25P128 and N25Q128 have the same capacity (16777216) - * but different number of sectors, pages per sector. - * Match the N25Q128 which is actually present on the board. - */ { - .idcode1 = 0x18, - .idcode = 0x20BB1810, + .idcode1 = 0x2018, + .page_size = 256, + .pages_per_sector = 1024, + .nr_sectors = 64, + .name = "M25P128", + }, + { + .idcode1 = 0xBB18, .page_size = 256, .pages_per_sector = 256, .nr_sectors = 256, .name = "N25Q128_1.8V", }, { - .idcode1 = 0x18, - .idcode = 0x20BA1810, + .idcode1 = 0xBA18, .page_size = 256, .pages_per_sector = 256, .nr_sectors = 256, .name = "N25Q128_3V", }, - { - .idcode1 = 0x18, - .page_size = 256, - .pages_per_sector = 1024, - .nr_sectors = 64, - .name = "M25P128", - }, }; static int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len) @@ -165,21 +153,13 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) { params = &stmicro_spi_flash_table[i]; - if (params->idcode1 == idcode[2]) { - if (params->idcode == 0) { - break; - } - /* Check complete device ID, if specified */ - if ((((params->idcode & 0xFF000000) >> 24) == idcode[0]) && - (((params->idcode & 0x00FF0000) >> 16) == idcode[1]) && - (((params->idcode & 0x000000FF) >> 0) == idcode[3])) { - break; - } - } + if (params->idcode1 == ((idcode[1] << 8) | idcode[2])) + break; } if (i == ARRAY_SIZE(stmicro_spi_flash_table)) { - debug("SF: Unsupported STMicro ID %02x\n", idcode[1]); + debug("SF: Unsupported STMicro ID %02x %02x\n", + idcode[1], idcode[2]); return NULL; } -- 2.47.3