]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/spi/stmicro.c
sf: sst: add sst25vf###b ids
[u-boot] / drivers / mtd / spi / stmicro.c
index b8b835a3ffe6f8e19886e0ed08a7c648ec2adac8..9b910c13fd8b16f13fb92543d07f2e8e859d684e 100644 (file)
@@ -64,9 +64,10 @@ struct stmicro_spi_flash_params {
        const char *name;
 };
 
+/* spi_flash needs to be first so upper layers can free() it */
 struct stmicro_spi_flash {
-       const struct stmicro_spi_flash_params *params;
        struct spi_flash flash;
+       const struct stmicro_spi_flash_params *params;
 };
 
 static inline struct stmicro_spi_flash *to_stmicro_spi_flash(struct spi_flash
@@ -132,10 +133,10 @@ static int stmicro_wait_ready(struct spi_flash *flash, unsigned long timeout)
        struct spi_slave *spi = flash->spi;
        unsigned long timebase;
        int ret;
+       u8 cmd = CMD_M25PXX_RDSR;
        u8 status;
-       u8 cmd[4] = { CMD_M25PXX_RDSR, 0xff, 0xff, 0xff };
 
-       ret = spi_xfer(spi, 32, &cmd[0], NULL, SPI_XFER_BEGIN);
+       ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);
        if (ret) {
                debug("SF: Failed to send command %02x: %d\n", cmd, ret);
                return ret;
@@ -294,8 +295,7 @@ int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
                        break;
                }
 
-               /* Up to 2 seconds */
-               ret = stmicro_wait_ready(flash, 2 * CONFIG_SYS_HZ);
+               ret = stmicro_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
                if (ret < 0) {
                        debug("SF: STMicro page erase timed out\n");
                        break;
@@ -314,12 +314,6 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
        const struct stmicro_spi_flash_params *params;
        struct stmicro_spi_flash *stm;
        unsigned int i;
-       int ret;
-       u8 id[3];
-
-       ret = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id));
-       if (ret)
-               return NULL;
 
        for (i = 0; i < ARRAY_SIZE(stmicro_spi_flash_table); i++) {
                params = &stmicro_spi_flash_table[i];
@@ -329,7 +323,7 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
        }
 
        if (i == ARRAY_SIZE(stmicro_spi_flash_table)) {
-               debug("SF: Unsupported STMicro ID %02x\n", id[1]);
+               debug("SF: Unsupported STMicro ID %02x\n", idcode[1]);
                return NULL;
        }