s25fl128s 是一个spi接口的norflash芯片,spansion公司出品。
这里使用drivers/mtd/devices/mxc_m25p80.c这个驱动。
这个驱动兼容了好多公司个spi-flash芯片,如ST 的m25p80系列,Atmel at25系列,Macronix的mx25系列,SST的sst25系列,Spansion的s25系列等等。
这个驱动能给这么多spi设备共用~ 呵呵,真了不起,可见spi-flash的标准定得挺不错的,大家都挺给脸的。
下面这个是spi_device的设备表,用来查询和配置各型号spi-flash信息:
/* NOTE: double check command sets and memory organization when you add
* more flash chips. This current list focusses on newer chips, which
* have been converging on command sets which including JEDEC ID.
*/
static const struct spi_device_id m25p_ids[] = {
/* Atmel -- some are (confusingly) marketed as "DataFlash" */
{"at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K)},
{"at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K)},
{"at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K)},
{"at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K)},
{"at26f004", INFO(0x1f0400, 0, 64 * 1024, 8, SECT_4K)},
{"at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K)},
{"at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K)},
{"at26df321", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K)},
/* Macronix */
{"mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K)},
{"mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, 0)},
{"mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0)},
{"mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0)},
{"mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0)},
/* Spansion -- single (large) sector size only, at least
* for the chips listed here (without boot sectors).
*/
{"s25sl004a", INFO(0x010212, 0, 64 * 1024, 8, 0)},
{"s25sl008a", INFO(0x010213, 0, 64 * 1024, 16, 0)},
{"s25sl016a", INFO(0x010214, 0, 64 * 1024, 32, 0)},
{"s25sl032a", INFO(0x010215, 0, 64 * 1024, 64, 0)},
{"s25sl064a", INFO(0x010216, 0, 64 * 1024, 128, 0)},
{"s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0)},
{"s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0)},
{"s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024, 64, 0)},
{"s25fl129p1", INFO(0x012018, 0x4d01, 64 * 1024, 256, 0)},
/* add by lxu*/
{"s25fl128s", INFO(0x012018, 0, 64 * 1024, 256, 0)},
...
前面毫无疑问,肯定是芯片名字了,后面的是deviceid, 每个芯片的手册上都有注明的,各公司各型号都不会相同。
这个device id会在后面的jedec_probe中被读取出来,并比较,用来确定是哪个芯片型号。
probe函数如下:
/*
* board specific setup should have ensured the SPI clock used here
* matches what the READ command supports, at least until this driver
* understands FAST_READ (for clocks over 25 MHz).
*/
static int __devinit m25p_probe(struct spi_device *spi)
{
const struct spi_device_id *id = spi_get_device_id(spi);
struct flash_platform_data *data;
struct m25p *flash;
struct flash_info *info;
unsigned i;
/* Platform data helps sort out which chip type we have, as
* well as how this board partitions it. If we don't have
* a chip ID, try the JEDEC id commands; they'll work for most
* newer chips, even if we don't recognize the particular chip.
*/
data = &s25fl128s_spi_flash_data;
if (data && data->type) {
const struct spi_device_id *plat_id;
for (i = 0; i < ARRAY_SIZE(m25p_ids) - 1; i++) {
plat_id = &m25p_ids[i];
if (strcmp(data->type, plat_id->name))