mini6410移植全攻略(11)--linux2.6.39 移植之支持nand flash (上) .
mini6410移植全攻略(11)--linux2.6.39 移植之支持nand flash (上) .本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。
转载请注明出处:http://blog.csdn.net/muge0913/article/details/7242620
一、修改arch/arm/mach-s3c64xx/mach-th6410.c文件
1)注册platform设备(nand)。
在static struct platform_device *th6410_devices[]__initdata中加入:
view plaincopyprint?01.&samsung_asoc_dma,
02.#if 0
03. &s3c64xx_device_iisv4,
04. &samsung_device_keypad,
05.#endif
06.//muge0913 add it
07. &s3c_device_nand,
08.#ifdef CONFIG_REGULAT
&samsung_asoc_dma,
#if 0
&s3c64xx_device_iisv4,
&samsung_device_keypad,
#endif
//muge0913 add it
&s3c_device_nand,
#ifdef CONFIG_REGULAT 注:关于nandflash平台设备更多知识在arch/arm/plat-samsung/dev-nand.c和arch/arm/plat-samsung/include/plat/nand.h以及arch/arm/plat-samsung/include/plat/regs-nand.hdev-nand.c:定义了nand平台设备、nand平台设备所需资源、平台的一些数据信息等。nand.h:定义了芯片本身相关的信息、bsp对nandflash的一些时序设置信息等。regs-nand.h:CPU中NANDFLASH各种寄存器的定义。
2)添加分区、时序等
view plaincopyprint?01./*
02. * Configuring Nandflash on TH6410
03. */
04.vi arch/arm/mach-s3c64xx/mach-th6410.c
05.
06.第117行
07.
08.struct mtd_partition mini6410_nand_part[] = {
09.
10. {
11.
12. .name = "Bootloader",
13.
14. .offset = 0,
15.
16. .size = (4 * 128 *SZ_1K),
17.
18. .mask_flags = MTD_CAP_NANDFLASH,
19.
20. },
21.
22. {
23.
24. .name = "Kernel",
25.
26. .offset = (4 * 128 *SZ_1K),
27.
28. .size = (5*SZ_1M) ,
29.
30. .mask_flags = MTD_CAP_NANDFLASH,
31.
32. },
33.
34. {
35.
36. .name = "File System",
37.
38. .offset = MTDPART_OFS_APPEND,
39.
40. .size = MTDPART_SIZ_FULL,
41.
42. }
43.
44.};
/*
* Configuring Nandflash on TH6410
*/
vi arch/arm/mach-s3c64xx/mach-th6410.c
第117行
struct mtd_partition mini6410_nand_part[] = {
{
.name = "Bootloader",
.offset = 0,
.size = (4 * 128 *SZ_1K),
.mask_flags = MTD_CAP_NANDFLASH,
},
{
.name = "Kernel",
.offset = (4 * 128 *SZ_1K),
.size = (5*SZ_1M) ,
.mask_flags = MTD_CAP_NANDFLASH,
},
{
.name = "File System",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
}; 3)向内核注册信息。
在static void __init th6410_machine_init(void)函数中,添加如下代码:
view plaincopyprint?01.//muge0913 add codes here
02.
03.#ifdefCONFIG_MTD_NAND_S3C
04.
05.s3c_device_nand.name = "s3c6410-nand";
06.
07.#endif
08.
09. s3c_nand_set_platdata(&th6410_nand_info);
//muge0913 add codes here
#ifdefCONFIG_MTD_NAND_S3C
s3c_device_nand.name = "s3c6410-nand";
#endif
s3c_nand_set_platdata(&th6410_nand_info);二、修改s3c_nand.c文件
其实该文件开源的百度即有。可以查看已修好的s3c_nand.c文件。
1)修改drivers/mtd/nand/目录下的KconfigKconfig:添加下面部分
view plaincopyprint?01.configMTD_NAND_S3C2410_HWECC
02. bool "Samsung S3C NAND Hardware ECC"
03. depends on MTD_NAND_S3C2410
04. help
05. Enable the use of the controller's internal ECCgenerator when
06. using NAND. Early versions of the chips have hadproblems with
07. incorrect ECC generation, and if using these, thedefault of
08. software ECC is preferable.
09.
10.config MTD_NAND_S3C
11. tristate "NAND Flash support for S3C SoC"
12. depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX)&& MTD_NAND
13. help
14. This enables the NAND flash controller on the S3C.
15. No board specfic support is done by this driver, eachboard
16. must advertise a platform_device for the driver toattach.
17.config MTD_NAND_S3C_DEBUG
18. bool "S3C NAND driver debug"
19. depends on MTD_NAND_S3C
20. help
21. Enable debugging of the S3C NAND driver
22.config MTD_NAND_S3C_HWECC
23. bool "S3C NAND Hardware ECC"
24. depends on MTD_NAND_S3C
25. help
26. Enable the use of the S3C's internal ECC generatorwhen
27. using NAND. Early versions of the chip have hadproblems with
28. incorrect ECC generation, and if using these, the defaultof
29. software ECC is preferable.
30. If you lay down a device with the hardware ECC, thenyou will
31. currently not be able to switch to software, as thereis no
32. implementation for ECC method used by the S3C
33.config MTD_NAND_NDFC
34. tristate "NDFC NanD Flash Controller"
35. depends on 4xx
36. select MTD_NAND_ECC_SMC
37. help
38. NDFC Nand Flash Controllers are integrated in IBM/AMCC's4xx SoCs
configMTD_NAND_S3C2410_HWECC
bool "Samsung S3C NAND Hardware ECC"
depends on MTD_NAND_S3C2410
help
Enable the use of the controller's internal ECCgenerator when
using NAND. Early versions of the chips have hadproblems with
incorrect ECC generation, and if using these, thedefault of
software ECC is preferable.
config MTD_NAND_S3C
tristate "NAND Flash support for S3C SoC"
depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX)&& MTD_NAND
help
This enables the NAND flash controller on the S3C.
No board specfic support is done by this driver, eachboard
must advertise a platform_device for the driver toattach.
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_HWECC
bool "S3C NAND Hardware ECC"
depends on MTD_NAND_S3C
help
Enable the use of the S3C's internal ECC generatorwhen
using NAND. Early versions of the chip have hadproblems with
incorrect ECC generation, and if using these, the defaultof
software ECC is preferable.
If you lay down a device with the hardware ECC, thenyou will
currently not be able to switch to software, as thereis no
implementation for ECC method used by the S3C
config MTD_NAND_NDFC
tristate "NDFC NanD Flash Controller"
depends on 4xx
select MTD_NAND_ECC_SMC
help
NDFC Nand Flash Controllers are integrated in IBM/AMCC's4xx SoCs 2) 修改Makfile告知内核编译s3c_nand.c
Makefile:添加下面部分
view plaincopyprint?
01.obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o改好后保存退出
三、 当然drivers/mtd/nand/s3c_nand_mlc.fo
也要拷贝过来,这是友善没有开源的一个驱动之一,所以不用研究了,拷过来就是了。
四、修改drivers/mtd/nand/nand_base.c文件
直接将drivers/mtd/nand/nand_base.c拷过来覆盖就可以了。
五、编译内核
然后再1)make menuconfig
Device Drivers--->
<*> Memory Technology Device(MTD) support--->
[*]MTD partitioning support
[*] Command line partition table parsing
<*>Direct char device access to MTD devices
<*>Caching block device access to MTD devices
<*>NAND Device Support--->
< > NAND Flash support forSamsung S3C SoCs去掉不要选
<*> NAND Flash support for S3C SoC
[*] S3C NAND Hardware ECC
2)make zImage
谢谢分享 参观参观
sfp 其实我很想知道它的那个没开源驱动,自己写裸板是在不方便 不要和我比懒,我懒得和你比
顶上去
signature..................................
仙府之缘
页:
[1]