[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] drivers/mtd/chips/jedec_probe.c MTD M25P16 SPI Flash Problems
Smajic Eldin a écrit :
Hi John,
I have here something to add which could maybe tell you more about the status of my system regarding "Mounting SPI Flash". I posted below the contents of 'iomem' which tells that there is a xilinx_spi.0 device which is my SPI Flash. But the strange thing is, that there is no blockdevice for that in '/dev/'...
Console:
***************************************
# cd /
# ls
bin dev etc home lib mnt proc sys tmp usr var
# cd proc/
# ls
1 45 bus interrupts meminfo stat
10 46 cmdline iomem misc sys
11 47 cpuinfo ioports modules tty
12 5 devices irq mounts uptime
13 6 diskstats kallsyms mtd version
2 7 driver kmsg net vmstat
264 8 execdomains loadavg partitions zoneinfo
3 9 filesystems locks self
4 buddyinfo fs maps slabinfo
# cat iomem
4a000000-4a1fffff : xilinx_spi.0
81400000-8140ffff : xilinx_gpio.0
81400000-8140ffff : xilinx_gpio
84000000-8400ffff : uartlite.0
84000000-8400000f : uartlite
***************************************
It would be great if you could help me taking this final step.
Thank you.
Eldin
Hi Eldin,
A little help from myself about using SPI flash with Microblaze
the previous steps are OK
i think you have to select M25P80 driver in make menuconfig -> Devices
Drivers -> Memory Technology Devices (MTD) -> Self contained MTD ->
Support for M25 spi flash
then copy these platform initialisers to
linux-2.6.x-petalogix/arch/microblaze/platform/common
for M25p80
#include <linux/autoconf.h>
#include <linux/init.h>
#include <linux/resource.h>
#include <linux/xilinx_devices.h>
#include <linux/serial_8250.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
static struct flash_platform_data m25p32_info = {
.name = "m25p32",
.type = "m25p32",
.nr_parts = 1,
};
static struct __initdata spi_board_info spi_board_info[] = {
{
.modalias = "m25p80",
.platform_data = &m25p32_info,
.mode = SPI_MODE_0,
.irq = 3,
.max_speed_hz = 50000000,
.bus_num = 0,
.chip_select = 0,
},
};
static int __init m25p32_platform_data(void)
{
int i;
spi_register_board_info(spi_board_info,ARRAY_SIZE(spi_board_info));
return 0;
}
device_initcall(m25p32_platform_data);
for xspi.c :
/*
* arch/microblaze/platform/common/xspi.c
*
* platform device initialisation for Xilinx SPI devices
*
* Copyright 2007 PetaLogix
*
* based on original kernel/platform.c which was
* Copyright 2007 LynuxWorks
*
* This file is licensed under the terms of the GNU General Public License
* version 2. This program is licensed "as is" without any warranty of any
* kind, whether express or implied.
*/
#include <linux/autoconf.h>
#include <linux/init.h>
#include <linux/resource.h>
#include <linux/xilinx_devices.h>
#include <linux/serial_8250.h>
#include <linux/spi/spi.h>
#define XSPI_PLATFORM_DATA_INITIALISER(n) \
{ \
.device_flags = (CONFIG_XILINX_SPI_##n##_FIFO_EXIST ? XSPI_HAS_FIFOS
: 0) | \
(CONFIG_XILINX_SPI_##n##_SPI_SLAVE_ONLY ? XSPI_SLAVE_ONLY : 0), \
.num_slave_bits = CONFIG_XILINX_SPI_##n##_NUM_SS_BITS \
}
#define XSPI_PLATFORM_DEVICE_INITIALISER(n) \
{ \
.name = "xilinx_spi", \
.id = (n), \
.dev.platform_data = &xspi_pdata[n], \
.num_resources = 2, \
.resource = (struct resource[]) { \
{ \
.start = CONFIG_XILINX_SPI_##n##_BASEADDR, \
.end = CONFIG_XILINX_SPI_##n##_HIGHADDR, \
.flags = IORESOURCE_MEM \
}, \
{ \
.start = CONFIG_XILINX_SPI_##n##_IRQ, \
.end = CONFIG_XILINX_SPI_##n##_IRQ, \
.flags = IORESOURCE_IRQ \
} \
} \
}
static struct xspi_platform_data xspi_pdata[] = {
#ifdef CONFIG_XILINX_SPI_0_INSTANCE
XSPI_PLATFORM_DATA_INITIALISER(0),
#endif
#ifdef CONFIG_XILINX_SPI_1_INSTANCE
XSPI_PLATFORM_DATA_INITIALISER(1),
#endif
#ifdef CONFIG_XILINX_SPI_2_INSTANCE
XSPI_PLATFORM_DATA_INITIALISER(2),
#endif
};
static struct platform_device xilinx_spi_device[] = {
#ifdef CONFIG_XILINX_SPI_0_INSTANCE
XSPI_PLATFORM_DEVICE_INITIALISER(0),
#endif
#ifdef CONFIG_XILINX_SPI_1_INSTANCE
XSPI_PLATFORM_DEVICE_INITIALISER(1),
#endif
#ifdef CONFIG_XILINX_SPI_2_INSTANCE
XSPI_PLATFORM_DEVICE_INITIALISER(2),
#endif
};
static int __init xspi_platform_init(void)
{
int i;
for(i=0;i<ARRAY_SIZE(xilinx_spi_device); i++)
platform_device_register(&xilinx_spi_device[i]);
return 0;
}
device_initcall(xspi_platform_init);
Modify the Makefile :
#
# Makefile for arch/microblaze/platform/common
#
#
# These are the platform device initialisers - even if the driver itself
# is built as a module (-m), we really probably want these guys built as -y
# So, build a local list of the -y and -m options, then concat and add them
# to obj-y
# Build a local list of -y and -m driver options.
platobj-$(CONFIG_MTD_PHYSMAP) += physmap-flash.o
platobj-$(CONFIG_XILINX_GPIO) += xgpio.o
platobj-$(CONFIG_SPI_XILINX) += xspi.o
platobj-$(CONFIG_MTD_M25P80) += m25p80.o
platobj-$(CONFIG_SERIAL_UARTLITE) += xuartlite.o
platobj-$(CONFIG_XILINX_SYSACE) += xsysace.o
platobj-$(CONFIG_INPUT_KEYPADDEV) += xbtn_decoder.o
obj-y += $(platobj-y) $(platobj-m)
# Make these platform setup sources dependent on .config
# This is necessary because fixdep is not smart enough to "look inside"
# the device struct initialiser macros and find the real dependencies
# on the CONFIG_XILINX_ macros, when we use macro string substitution
#
$(obj)/xsysace.o: .config
$(obj)/xuartlite.o: .config
$(obj)/xgpio.o: .config
$(obj)/xspi.o: .config
$(obj)/m25p80.o: .config
$(obj)/xbtn_decoder.o: .config
make clean all
make sure xilinx_spi.o spi.o spi_bitbang are compiled in
linux-2.6.x-petalogix/driver/spi
boot and verify lines
..............
m25p80 spi0.0: m25p32 (4096 Kbytes)
xilinx_spi xilinx.spi.0: at 0x40500000 mapped to 0x40500000, irq=1
..............
if it work you'll have now a second mtd device in /dev
cat /proc/mtd
mtd0: 00151000 00001000 "ROMfs"
mtd1: 00400000 00010000 "m25p32"
check the SPI also
cat /proc/iomem
40500000-4050ffff : xilinx_spi.0
40500000-4050ffff : xilinx_spi
......
.....
now how to create/mount jffs2 filesystem on SPI flash
first delete the flash with : eraseall /dev/mtd1
mkdir /tmp/test_flash
cd /tmp/
echo "dummy file" > dummy_file
mkfs.jffs2 -d /tmp > /dev/mtd1
mount -t jffs2 /dev/mtdblock1 /tmp/test_flash
mkfs.jffs2 eraseall are from busybox
et voila
Regards
Stéphane
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/