#include "spi_flash_internal.h"
-/* EN25Q128-specific commands */
-#define CMD_EN25Q128_SE 0x20 /* Sector Erase */
-#define CMD_EN25Q128_BE 0xd8 /* Block Erase */
-
struct eon_spi_flash_params {
u8 idcode1;
u16 nr_sectors;
},
};
-static int eon_erase(struct spi_flash *flash, u32 offset, size_t len)
-{
- return spi_flash_cmd_erase(flash, CMD_EN25Q128_BE, offset, len);
-}
-
struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
{
const struct eon_spi_flash_params *params;
flash->name = params->name;
flash->write = spi_flash_cmd_write_multi;
- flash->erase = eon_erase;
+ flash->erase = spi_flash_cmd_erase;
flash->read = spi_flash_cmd_read_fast;
flash->page_size = 256;
flash->sector_size = 256 * 16 * 16;
#include "spi_flash_internal.h"
-/* MX25xx-specific commands */
-#define CMD_MX25XX_SE 0x20 /* Sector Erase */
-#define CMD_MX25XX_BE 0xD8 /* Block Erase */
-#define CMD_MX25XX_CE 0xc7 /* Chip Erase */
-
struct macronix_spi_flash_params {
u16 idcode;
u16 nr_blocks;
return ret;
}
-static int macronix_erase(struct spi_flash *flash, u32 offset, size_t len)
-{
- return spi_flash_cmd_erase(flash, CMD_MX25XX_BE, offset, len);
-}
-
struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
{
const struct macronix_spi_flash_params *params;
flash->name = params->name;
flash->write = spi_flash_cmd_write_multi;
- flash->erase = macronix_erase;
+ flash->erase = spi_flash_cmd_erase;
flash->read = spi_flash_cmd_read_fast;
flash->page_size = 256;
flash->sector_size = 256 * 16 * 16;
#include "spi_flash_internal.h"
-/* S25FLxx-specific commands */
-#define CMD_S25FLXX_SE 0xd8 /* Sector Erase */
-#define CMD_S25FLXX_BE 0xc7 /* Bulk Erase */
-
struct spansion_spi_flash_params {
u16 idcode1;
u16 idcode2;
},
};
-static int spansion_erase(struct spi_flash *flash, u32 offset, size_t len)
-{
- return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE, offset, len);
-}
-
struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
{
const struct spansion_spi_flash_params *params;
flash->name = params->name;
flash->write = spi_flash_cmd_write_multi;
- flash->erase = spansion_erase;
+ flash->erase = spi_flash_cmd_erase;
flash->read = spi_flash_cmd_read_fast;
flash->page_size = 256;
flash->sector_size = 256 * params->pages_per_sector;
CMD_READ_STATUS, STATUS_WIP);
}
-int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd,
- u32 offset, size_t len)
+int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len)
{
u32 start, end, erase_size;
int ret;
return ret;
}
- cmd[0] = erase_cmd;
+ if (erase_size == 4096)
+ cmd[0] = CMD_ERASE_4K;
+ else
+ cmd[0] = CMD_ERASE_64K;
start = offset;
end = start + len;
#define CMD_WRITE_DISABLE 0x04
#define CMD_READ_STATUS 0x05
#define CMD_WRITE_ENABLE 0x06
+#define CMD_ERASE_4K 0x20
+#define CMD_ERASE_32K 0x52
+#define CMD_ERASE_64K 0xd8
+#define CMD_ERASE_CHIP 0xc7
/* Common status */
#define STATUS_WIP 0x01
int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout);
/* Erase sectors. */
-int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd,
- u32 offset, size_t len);
+int spi_flash_cmd_erase(struct spi_flash *flash, u32 offset, size_t len);
/* Manufacturer-specific probe functions */
struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode);
#define CMD_SST_BP 0x02 /* Byte Program */
#define CMD_SST_AAI_WP 0xAD /* Auto Address Increment Word Program */
-#define CMD_SST_SE 0x20 /* Sector Erase */
#define SST_SR_WIP (1 << 0) /* Write-in-Progress */
#define SST_SR_WEL (1 << 1) /* Write enable */
const struct sst_spi_flash_params *params;
};
-static inline struct sst_spi_flash *to_sst_spi_flash(struct spi_flash *flash)
-{
- return container_of(flash, struct sst_spi_flash, flash);
-}
-
-#define SST_SECTOR_SIZE (4 * 1024)
-#define SST_PAGE_SIZE 256
static const struct sst_spi_flash_params sst_spi_flash_table[] = {
{
.idcode1 = 0x8d,
return ret;
}
-static int sst_erase(struct spi_flash *flash, u32 offset, size_t len)
-{
- return spi_flash_cmd_erase(flash, CMD_SST_SE, offset, len);
-}
-
static int
sst_unlock(struct spi_flash *flash)
{
stm->flash.write = sst_write_wp;
else
stm->flash.write = spi_flash_cmd_write_multi;
- stm->flash.erase = sst_erase;
+ stm->flash.erase = spi_flash_cmd_erase;
stm->flash.read = spi_flash_cmd_read_fast;
- stm->flash.page_size = SST_PAGE_SIZE;
- stm->flash.sector_size = SST_SECTOR_SIZE;
+ stm->flash.page_size = 256;
+ stm->flash.sector_size = 4096;
stm->flash.size = stm->flash.sector_size * params->nr_sectors;
/* Flash powers up read-only, so clear BP# bits */
#include "spi_flash_internal.h"
/* M25Pxx-specific commands */
-#define CMD_M25PXX_SE 0xd8 /* Sector Erase */
-#define CMD_M25PXX_BE 0xc7 /* Bulk Erase */
#define CMD_M25PXX_RES 0xab /* Release from DP, and Read Signature */
struct stmicro_spi_flash_params {
},
};
-static int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
-{
- return spi_flash_cmd_erase(flash, CMD_M25PXX_SE, offset, len);
-}
-
struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
{
const struct stmicro_spi_flash_params *params;
flash->name = params->name;
flash->write = spi_flash_cmd_write_multi;
- flash->erase = stmicro_erase;
+ flash->erase = spi_flash_cmd_erase;
flash->read = spi_flash_cmd_read_fast;
flash->page_size = 256;
flash->sector_size = 256 * params->pages_per_sector;
#include "spi_flash_internal.h"
-/* M25Pxx-specific commands */
-#define CMD_W25_SE 0x20 /* Sector (4K) Erase */
-#define CMD_W25_BE 0xd8 /* Block (64K) Erase */
-#define CMD_W25_CE 0xc7 /* Chip Erase */
-
struct winbond_spi_flash_params {
uint16_t id;
uint16_t nr_blocks;
},
};
-static int winbond_erase(struct spi_flash *flash, u32 offset, size_t len)
-{
- return spi_flash_cmd_erase(flash, CMD_W25_SE, offset, len);
-}
-
struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
{
const struct winbond_spi_flash_params *params;
flash->name = params->name;
flash->write = spi_flash_cmd_write_multi;
- flash->erase = winbond_erase;
+ flash->erase = spi_flash_cmd_erase;
flash->read = spi_flash_cmd_read_fast;
flash->page_size = 4096;
flash->sector_size = 4096;