Hello,
I'm currently experiencing some problems with using MTD partitions in combination with S25FL128P SPI Flash from Spansion. I have defined which partitions should be created, but the don't end up in /dev/mtdblock0 and /dev/mtdblock1. I also don't get a /dev/mtd device. Could some here please point me in a direction where the source of my problem might lie?
I'm using the m25p80 SPI Flash driver and the Davinci SPI driver. Since the default Linux support package delivered with the OMAP L-137 processor only supports Winbond SPI Flash mounted on the EVM I updated the m25p80 driver since it supports the S25FL128P in the current git tree. The patches I applied can be found below.
I noticed that instead of the include/linux/spi/mtd_spi_flash.h the much simpler include/linux/spi/flash.h is used. I assume this cannot be the source of the problem. Is this assumption correct?
Status
- I don't have a /dev/mtd, /dev/mtdblock0 and /dev/mtdblock1
- When doing a cat /proc/mtd I only get an empty header
- ls in /sys/devices/platform results in:
root@10.3.3.130:/sys/devices/platform# ls
da8xx_lcdc.0 emac_davinci.1 i2c_davinci.1 ohci.0 serial8250.0
davinci-mmc.0 eqep.0 i2c_davinci.2 rtc-da8xx.0 uevent
dm_spi.0 eqep.1 musb_hdrc serial8250 watchdog
root@10.3.3.130:/sys/devices/platform#
- I would expect a spi_flash device to be present here since dm_spi is also present.
- Serial output shows (entire output is attached)
...
TCP reno registered
mxsp_spi: platform_device_register: 0
mxsp_spi: spi_register_board_info: 0
mxsp_spi: mxsp_spi_register: 0
sanity check
...
What have I done
Well I changed some files to try en get it to work, I'll try to sum them up as complete as possible.
- I've created a board file for the SPI operations mxsp_spi.c
static struct davinci_spi_platform_data mxsp_spi_pdata0 = {
.version = DAVINCI_SPI_VERSION_2,
.num_chipselect = 1,
.clk_name = "SPI0CLK",
};
static struct resource mxsp_spi_resources0[] = {
[0] = {
.start = DA8XX_SPI0_BASE,
.end = DA8XX_SPI0_BASE + 0xfff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_DA8XX_SPINT0,
.end = IRQ_DA8XX_SPINT0,
.flags = IORESOURCE_IRQ,
},
[2] = {
.start = DA8XX_DMACH_SPI0_RX,
.end = DA8XX_DMACH_SPI0_RX,
.flags = IORESOURCE_DMA | IORESOURCE_DMA_RX_CHAN,
},
[3] = {
.start = DA8XX_DMACH_SPI0_TX,
.end = DA8XX_DMACH_SPI0_TX,
.flags = IORESOURCE_DMA | IORESOURCE_DMA_TX_CHAN,
},
[4] = {
.start = EVENTQ_1,
.end = EVENTQ_1,
.flags = IORESOURCE_DMA | IORESOURCE_DMA_EVENT_Q,
},
};
static struct platform_device mxsp_spi_pdev0 = {
.name = "dm_spi",
.id = 0,
.resource = mxsp_spi_resources0,
.num_resources = ARRAY_SIZE(mxsp_spi_resources0),
.dev = {
.platform_data = &mxsp_spi_pdata0,
},
};
static struct mtd_partition mxsp_partitions[] = {
[0] = {
.name = "U-Boot Environment",
.offset = 0x100000,
.size = SZ_64K,
.mask_flags = MTD_WRITEABLE,
},
[1] = {
.name = "Firmware",
.offset = 0x200000,
.size = 0xb00000,
.mask_flags = 0,
},
};
struct davinci_spi_config_t s25fl128_spi_cfg = {
.wdelay = 0,
.odd_parity = 0,
.parity_enable = 0,
.wait_enable = 0,
.lsb_first = 0,
.timer_disable = 0,
.clk_high = 0,
.phase_in = 1,
.clk_internal = 1,
.loop_back = 0,
.cs_hold = 1,
.intr_level = 0,
.pin_op_modes = SPI_OPMODE_SPISCS_4PIN,
#ifndef CONFIG_SPI_INTERRUPT
.poll_mode = 1,
#endif
};
struct flash_platform_data s25fl128_spi_flash = {
.name = "Spansion SPI Flash",
.parts = mxsp_partitions,
.nr_parts = ARRAY_SIZE(mxsp_partitions),
.type = "25sl12800",
};
static struct spi_board_info mxsp_spi_board_info0[] = {
[0] = {
.modalias = "spi_flash",
.platform_data = &s25fl128_spi_flash,
.controller_data = &s25fl128_spi_cfg,
.mode = SPI_MODE_0,
.max_speed_hz = 37500000, /* max sample rate at 3V */
.bus_num = 0,
.chip_select = 0,
},
};
static int __init mxsp_spi_register(struct platform_device *pdev,
struct spi_board_info *bi,
unsigned int bi_size)
{
int ret = platform_device_register(pdev);
printk(KERN_INFO "mxsp_spi: platform_device_register: %d\n", ret);
if (ret)
return ret;
ret = spi_register_board_info(bi, bi_size);
printk(KERN_INFO "mxsp_spi: spi_register_board_info: %d\n", ret);
return ret;
}
static int __init mxsp_spi_board_init(void)
{
int ret = mxsp_spi_register(&mxsp_spi_pdev0, mxsp_spi_board_info0,
ARRAY_SIZE(mxsp_spi_board_info0));
printk(KERN_INFO "mxsp_spi: mxsp_spi_register: %d\n", ret);
printk("sanity check\n");
return ret;
}
-
I know this file is executed because the Linux serial output tells me it's all ok, see the status above.
- I set the following configuration switches
#
# Memory Technology Devices (MTD)
#
CONFIG_MTD=y
# CONFIG_MTD_DEBUG is not set
# CONFIG_MTD_CONCAT is not set
CONFIG_MTD_PARTITIONS=y
# CONFIG_MTD_REDBOOT_PARTS is not set
# CONFIG_MTD_CMDLINE_PARTS is not set
# CONFIG_MTD_AFS_PARTS is not set
#
# User Modules And Translation Layers
#
CONFIG_MTD_CHAR=y
CONFIG_MTD_BLOCK=y
# CONFIG_FTL is not set
# CONFIG_NFTL is not set
# CONFIG_INFTL is not set
# CONFIG_RFD_FTL is not set
#
# RAM/ROM/Flash chip drivers
#
# CONFIG_MTD_CFI is not set
# CONFIG_MTD_JEDECPROBE is not set
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
CONFIG_MTD_CFI_I1=y
CONFIG_MTD_CFI_I2=y
# CONFIG_MTD_CFI_I4 is not set
# CONFIG_MTD_CFI_I8 is not set
# CONFIG_MTD_RAM is not set
# CONFIG_MTD_ROM is not set
# CONFIG_MTD_ABSENT is not set
# CONFIG_MTD_OBSOLETE_CHIPS is not set
#
# Self-contained MTD device drivers
#
# CONFIG_MTD_DATAFLASH is not set
CONFIG_MTD_M25P80=y
CONFIG_M25PXX_USE_FAST_READ=y
# CONFIG_MTD_SPI_FLASH is not set
# CONFIG_MTD_SLRAM is not set
# CONFIG_MTD_PHRAM is not set
# CONFIG_MTD_MTDRAM is not set
# CONFIG_MTD_BLOCK2MTD is not set
- I manually applied the source code change which can be found in the following patches.
Addition of JEDEC support:http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fa0a8c71f352d89c54f2d3a92f7a8a97cdb7d9a4
Fast read support: