首先下载nand flash驱动 s3c_nand.c ,此文件包含着nand flash驱动具体的实现,将其复制到drivers/mtd/nand下;
s3c_nand.c 下载地址 s3c_nand.c
在s3c_nand.c中添加nand flash分区信息,分区内容可以自由设定。
#if defined(CONFIG_ARCH_S5PV210)
struct mtd_partition s3c_partition_info[] = {
{
.name= "misc",
.offset= (768*SZ_1K), /* for bootloader */
.size= (256*SZ_1K),
.mask_flags= MTD_CAP_NANDFLASH,
},
{
.name= "recovery",
.offset= MTDPART_OFS_APPEND,
.size= (5*SZ_1M),
},
{
.name= "kernel",
.offset= MTDPART_OFS_APPEND,
.size= (5*SZ_1M),
},
{
.name= "ramdisk",
.offset= MTDPART_OFS_APPEND,
.size= (3*SZ_1M),
},
{
.name= "system",
.offset= MTDPART_OFS_APPEND,
.size= MTDPART_SIZ_FULL,
}
{
.name= "system",
.offset= MTDPART_OFS_APPEND,
.size= (110*SZ_1M),
},
{
.name= "cache",
.offset= MTDPART_OFS_APPEND,
.size= (80*SZ_1M),
},
{
.name= "userdata",
.offset= MTDPART_OFS_APPEND,
.size= MTDPART_SIZ_FULL,
}
#endif
};
struct s3c_nand_mtd_info s3c_nand_mtd_part_info = {
.chip_nr = 1,
.mtd_part_nr = ARRAY_SIZE(s3c_partition_info),
.partition = s3c_partition_info,
};
结构体s3c_nand_mtd_info在源代码是没有的,所以要将其添加进去;
为了能使s3c_nand.c正确编译,还要修改该目录下,也就是的drivers/mtd/nand的Makefile和Kconfig:
在Mach-smdkv210.c (archarmmach-s5pv210) 中添加nand flash source,platform_device,需要头文件map.h map.h下载,下载将其放在(archarmmach-s5pv210includemach),在Mach-smdkv210.c中加入#include <asm/mach/map.h>。替换掉map.h文件
添加nand flash source
/* NAND Controller */
static struct resource s3c_nand_resource[] = {
[0] = {
.start= S5PV210_PA_NAND,
.end= S5PV210_PA_NAND + S5PV210_SZ_NAND - 1,
.flags= IORESOURCE_MEM,
}
};
struct platform_device s3c_device_nand = {
.name= "s5pv210-nand",
.id= -1,
.num_resources= ARRAY_SIZE(s3c_nand_resource),
.resource= s3c_nand_resource,
};
添加platform_device
找到static struct platform_device *smdkv210_devices[] __initdata
添加
添加时钟信息
在Clock.c (archarmmach-s5pv210) 中找到static struct clk init_clocks_off[],添加
{
.name = "nand",
.id = -1,
.parent = &clk_hclk_psys.clk,
.enable = s5pv210_clk_ip1_ctrl,
.ctrlbit = ((1 << 28) | (1 << 24)),
},
添加之后,nand flash驱动才能正确获取时钟。
以上操作完成后,开始配置内核
根目录下make menuconfig
到了这里,开发板已经支持nand flash驱动。
接下来
配置后保存,make clean ,make zImage
将zImage下载进开发板。从串口信息可以看出nand flash驱动是否完成:
S3C NAND Driver, (c) 2008 Samsung Electronics
S3C NAND Driver is using hardware ECC.
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Creating 5 MTD partitions on "s5pv210-nand":
0x0000000c0000-0x000000100000 : "misc"
0x000000100000-0x000000600000 : "recovery"
0x000000600000-0x000000b00000 : "kernel"
0x000000b00000-0x000000e00000 : "ramdisk"
0x000000e00000-0x000010000000 : "system"