]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Xilinx: ARM: sf: stmicro: Support for numonyx ID table
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Sat, 25 Aug 2012 17:58:06 +0000 (23:28 +0530)
committerJohn Linn <john.linn@xilinx.com>
Wed, 29 Aug 2012 23:11:07 +0000 (16:11 -0700)
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 <jaganna@xilinx.com>
drivers/mtd/spi/stmicro.c

index 31fb42329d0c651c0636437bc2e4bf9bb6dc424a..9c85620d7f181a33fb46db01e18cedb164ce1d99 100644 (file)
 #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;
        }