2 * (C) Copyright 2010, ucRobotics Inc.
3 * Author: Chong Huang <chuang@ucrobotics.com>
4 * Licensed under the GPL-2 or later.
11 #include "spi_flash_internal.h"
13 /* EN25Q128-specific commands */
14 #define CMD_EN25Q128_SE 0x20 /* Sector Erase */
15 #define CMD_EN25Q128_BE 0xd8 /* Block Erase */
17 struct eon_spi_flash_params {
23 static const struct eon_spi_flash_params eon_spi_flash_table[] = {
41 static int eon_erase(struct spi_flash *flash, u32 offset, size_t len)
43 return spi_flash_cmd_erase(flash, CMD_EN25Q128_BE, offset, len);
46 struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
48 const struct eon_spi_flash_params *params;
49 struct spi_flash *flash;
52 for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) {
53 params = &eon_spi_flash_table[i];
54 if (params->idcode1 == idcode[2])
58 if (i == ARRAY_SIZE(eon_spi_flash_table)) {
59 debug("SF: Unsupported EON ID %02x\n", idcode[1]);
63 flash = malloc(sizeof(*flash));
65 debug("SF: Failed to allocate memory\n");
70 flash->name = params->name;
72 flash->write = spi_flash_cmd_write_multi;
73 flash->erase = eon_erase;
74 flash->read = spi_flash_cmd_read_fast;
75 flash->page_size = 256;
76 flash->sector_size = 256 * 16 * 16;
77 flash->size = 256 * 16