[arm@localhost linux-2.6.14]$ vi arch/arm/mach-s3c2410/devs.c
添加如下内容:
#include
#include
#include ...
/* NAND Controller */
1.建立Nand Flash 分区表
/* 一个Nand Flash 总共64MB, 按如下大小进行分区 */
static struct mtd_partition partition_info[] ={
{ /* 1MB */
name: \
size: 0x00100000,
offset: 0x0,
},{ /* 3MB */
name: \
size: 0x00300000,
offset: 0x00100000,
}, { /* 40MB */
name: \
size: 0x02800000,
offset: 0x00400000,
}, { /* 20MB */
name: \
size: 0x00f00000,
offset: 0x02d00000,
} };
name: 代表分区名字
size: 代表flash 分区大小(单位:字节)
offset: 代表flash 分区的起始地址(相对于0x0 的偏移)
目标板计划分4 个区,分别存放bootloader, kernel, rootfs 以及以便以后扩展使用的用户文件系统空间。
各分区在Nand flash 中起始地址. 分区大小. 记录如下:
----------------------- 页面 54-----------------------
bootloader:
start: 0x00000000
len: 0x00100000
1MB
kernel:
start: 0x00100000
len: 0x00300000
3MB
rootfs:
start: 0x00400000
len: 0x02800000
40MB
User:
start: 0x02c00000
len: 0x01400000
20MB
2. 加入Nand Flash 分区
struct s3c2410_nand_set nandset ={
nr_partitions: 4, /* the number of partitions */
partitions: partition_info, /* partition table */ };
nr_partitions: 指明partition_info 中定义的分区数目
partitions: 分区信息表
3. 建立Nand Flash 芯片支持
struct s3c2410_platform_nand superlpplatform={
tacls:0,
twrph0:30,
twrph1:0,
sets: &nandset,
nr_sets: 1, };
tacls, twrph0, twrph1 的意思见S3C2410 手册的6-3, 这3 个值最后会被设置到NFCONF 中,见S3C2410 手册6-6.
sets: 支持的分区集
nr_set:分区集的个数
4. 加入Nand Flash 芯片支持到Nand Flash 驱动
另外,还要修改此文件中的s3c_device_nand 结构体变量,添加对dev 成员的赋值
struct platform_device s3c_device_nand = {
.name = \
.id = -1, /* Device ID */
.num_resources = ARRAY_SIZE(s3c_nand_resource),
.resource = s3c_nand_resource, /* Nand Flash Controller Registers */
/* Add the Nand Flash device */
.dev = {
.platform_data = &superlpplatform
} };
----------------------- 页面 55-----------------------
name: 设备名称
id: 有效设备编号,如果只有唯一的一个设备为-1, 有多个设备从0 开始计数.
num_resource: 有几个寄存器区
resource: 寄存器区数组首地址
dev: 支持的Nand Flash 设备
1.3.2 指定启动时初始化
kernel 启动时依据我们对分区的设置进行初始配置
修改arch/arm/mach-s3c2410/mach-smdk2410.c 文件
[arm@localhost linux-2.6.14]$ vi arch/arm/mach-s3c2410/mach-smdk2410.c
修改smdk2410_devices[].指明初始化时包括我们在前面所设置的flash 分区信息
static struct platform_device *smdk2410_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,