W25Q32是一个spi接口的存放芯片, 容量32M比特(4M字节).
驱动文件在"drivers/mtd/devices/m25p80.c"
static struct spi_driver m25p80_driver = {
.driver = {
.name = "m25p80",
.of_match_table = m25p_of_table,
},
.id_table = m25p_ids, //使用id_table来匹配
.probe = m25p_probe,
.remove = m25p_remove,
};
//支持的芯片型号
static const struct spi_device_id m25p_ids[] = {
...
{"at25df321a"}, {"at25df641"}, {"at26df081a"},
{"mx25l4005a"}, {"mx25l1606e"}, {"mx25l6405d"}, {"mx25l12805d"},
{"mx25l25635e"},{"mx66l51235l"},
{"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q512a"},
{"s25fl256s1"}, {"s25fl512s"}, {"s25sl12801"}, {"s25fl008k"},
{"s25fl064k"},
{"sst25vf040b"},{"sst25vf016b"},{"sst25vf032b"},{"sst25wf040"},
{"m25p40"}, {"m25p80"}, {"m25p16"}, {"m25p32"},
{"m25p64"}, {"m25p128"},
{"w25x80"}, {"w25x32"}, {"w25q32"}, {"w25q32dw"},
{"w25q80bl"}, {"w25q128"}, {"w25q256"},
...
};
w25q32接在spi0接口,在设备树文件里的描述:
&spi0 {
status = "okay";
spiflash {
compatible = "w25q32"; //设备名就为"w25q32"与设备驱动里的id_table项匹配
reg = <0>;
status = "okay";
spi-max-frequency = <10000000>;
buswidth = <8>;
};
};
因设备驱动提供的是mtd接口,所以设备驱动与设备匹配后会产生"mtd0 mtdblock0"等设备文件
mkfs.ext2 /dev/mtdblock0 //先格式化设备分区
mount /dev/mtdblock0 /mnt //再挂载上来操作即可