<七> Nand flash 驱动的移植

1.拷贝 regs-nand.h 到 arch/arm/mach-s5pv210/include/mach/
2.拷贝 s3c_nand.c 到 drivers/mtd/nand/
3.修改平台代码:
vim arch/arm/mach-s5pv210/mach-smdkv210.c
添加头文件
#ifdef CONFIG_MTD_NAND
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/mtd/partitions.h>
#include <plat/nand.h>
#endif
添加平台设备
#ifdef CONFIG_MTD_NAND
static struct mtd_partition s5pv210_partition_info[] = {
[0] = {
.name = "Bootloader",
.offset = 0,
.size = SZ_1M,
},
[1] = {
.name = "Kernel",
.offset = MTDPART_OFS_APPEND,
.size = SZ_1M * 4,
},[2] = {
.name = "Rootfs",
.offset = MTDPART_OFS_APPEND,
.size = SZ_8M,
},
[3] = {
.name = "Userfs",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
},
};
struct s3c_nand_mtd_info s5pv210_nand_info = {
.chip_nr = 1,
.mtd_part_nr = ARRAY_SIZE(s5pv210_partition_info),
.partition = s5pv210_partition_info
};
struct resource s5pv210_nand_resource[] = {
[0] = {
.start = 0xB0E00000,
.end = 0xB0E00000 + SZ_1M,
.flags = IORESOURCE_MEM,
},
};
struct platform_device s5pv210_device_nand = {
.name = "s5pv210-nand",
.id = -1,
.num_resources = ARRAY_SIZE(s5pv210_nand_resource),
.resource = s5pv210_nand_resource,
.dev = {
.platform_data = &s5pv210_nand_info,
},
};
#endif
在结构体数组 smdkv210_devices[]中添加
static struct platform_device *smdkv210_devices[] __initdata = {
……
#if defined(CONFIG_MTD_NAND)
&s5pv210_device_nand,
#endif
};修改 arch/arm/plat-samsung/include/plat/nand.h 添加如下内容:
struct s3c_nand_mtd_info {
uint chip_nr;
uint mtd_part_nr;
struct mtd_partition *partition;
};
修改 include/linux/mtd/partitions.h
添加
int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
修改 arch/arm/mach-s5pv210/clock.c 中结构体在最后添加如下代码(加粗部分)
static struct clk init_clocks_off[] = {
{
……
.ctrlbit = (1 << 0),
},{
.name = "nandxl",
.id = -1,
.parent = &clk_hclk_psys.clk,
.enable = s5pv210_clk_ip1_ctrl,
.ctrlbit = (1 << 24),
},
};
修改 drivers/mtd/nand/Kconfig
在 213 行添加如下代码:
config MTD_NAND_S3C
tristate "NAND Flash support for S3C SoC"
depends on MTD_NAND && (ARCH_S5PC1XX || ARCH_S5PC11X || ARCH_S5PV2XX ||
ARCH_S5PV210)
help
This enables the NAND flash controller on the S3C.
No board specfic support is done by this driver, each board
must advertise a platform_device for the driver to attach.
config MTD_NAND_S3C_DEBUG
bool "S3C NAND driver debug"
depends on MTD_NAND_S3C
help
Enable debugging of the S3C NAND driver
config MTD_NAND_S3C_HWECCbool "S3C NAND Hardware ECC"
depends on MTD_NAND_S3C
help
Enable the use of the S3C's internal ECC generator when
using NAND. Early versions of the chip have had problems with
incorrect ECC generation, and if using these, the default of
software ECC is preferable.
If you lay down a device with the hardware ECC, then you will
currently not be able to switch to software, as there is no
implementation for ECC method used by the S3C
修改 drivers/mtd/nand/Makefile

obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o
下面添加:
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o
4.配置内核:
make menuconfig
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
<*> Caching block device access to MTD devices
<*> NAND Device Support --->
<*> NAND Flash support for S3C SoC
[*] S3C NAND Hardware ECC
File systems --->
Partition Types --->
[*] Advanced partition selection
[*] PC BIOS (MSDOS partition tables) support
[*] BSD disklabel (FreeBSD partition tables) support
5.编译内核并拷贝到 tftpboot 下
$ make zImage
$ cp arch/arm/boot/zImage /tftpboot
6.在开发板上执行如下操作:
# cat /proc/partitions
31 0 1024 mtdblock0
31 1 4096 mtdblock1
31 2 8192 mtdblock2
31 3 1036288 mtdblock3(不一样没事)
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值