2 * Copyright 2008, Network Appliance Inc.
3 * Author: Jason McMullan <mcmullan <at> netapp.com>
4 * Licensed under the GPL-2 or later.
11 #include "spi_flash_internal.h"
13 /* M25Pxx-specific commands */
14 #define CMD_W25_SE 0x20 /* Sector (4K) Erase */
15 #define CMD_W25_BE 0xd8 /* Block (64K) Erase */
16 #define CMD_W25_CE 0xc7 /* Chip Erase */
18 struct winbond_spi_flash_params {
24 static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
72 static int winbond_erase(struct spi_flash *flash, u32 offset, size_t len)
74 return spi_flash_cmd_erase(flash, CMD_W25_SE, offset, len);
77 struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
79 const struct winbond_spi_flash_params *params;
80 struct spi_flash *flash;
83 for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) {
84 params = &winbond_spi_flash_table[i];
85 if (params->id == ((idcode[1] << 8) | idcode[2]))
89 if (i == ARRAY_SIZE(winbond_spi_flash_table)) {
90 debug("SF: Unsupported Winbond ID %02x%02x\n",
91 idcode[1], idcode[2]);
95 flash = malloc(sizeof(*flash));
97 debug("SF: Failed to allocate memory\n");
102 flash->name = params->name;
104 flash->write = spi_flash_cmd_write_multi;
105 flash->erase = winbond_erase;
106 flash->read = spi_flash_cmd_read_fast;
107 flash->page_size = 4096;
108 flash->sector_size = 4096;
109 flash->size = 4096 * 16 * params->nr_blocks;