close
linux 好像都是用 CONFIG_MTD_M25P80 這個 module 去驅動大部份的 spi flash

在 mach-omap2/board-am335xevm.c 裡面我加了下面的宣告

static const struct flash_platform_data am335x_spi_flash = {
.type = "mx25l25635e",
.name = "spi_flash",
.parts = am335x_spi_partitions,
.nr_parts = ARRAY_SIZE(am335x_spi_partitions),
};

static struct spi_board_info am335x_spi0_slave_info[] = {
{
.modalias = "m25p80",
.platform_data = &am335x_spi_flash,
.irq = -1,
.max_speed_hz = 24000000,
.bus_num = 1,
.chip_select = 0,
.mode = SPI_MODE_3,
},
};

在 drivers/mtd/devices/m25p80.c 已經有大部份的spi flash id
/* Macronix */
{ "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) },
{ "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) },
{ "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, 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) },
{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },


開機可以看到 這些partition 跑出來
[ 8.159545] Creating 10 MTD partitions on "spi_flash":
[ 8.165008] 0x000000000000-0x000000020000 : "SPL"
[ 8.171875] 0x000000020000-0x000000050000 : "U-Boot"
[ 8.178833] 0x000000050000-0x000000060000 : "U-Boot Env"
[ 8.186187] 0x000000060000-0x000000080000 : "Def-config"
[ 8.193572] 0x000000080000-0x0000000a0000 : "Cur-config"
[ 8.200775] 0x0000000a0000-0x000000100000 : "User-data"
[ 8.207916] 0x000000100000-0x000000480000 : "KernelA"
[ 8.214874] 0x000000480000-0x000000800000 : "KernelB"
[ 8.221862] 0x000000800000-0x000001400000 : "rootfsA"
[ 8.228912] 0x000001400000-0x000002000000 : "rootfsB"
arrow
arrow
    文章標籤
    linux spi
    全站熱搜

    jchuang1977 發表在 痞客邦 留言(0) 人氣()