Friendly arm mini2440: Analysis of NAND Flash Driver in Embedded Linux

Source: Internet
Author: User
Analysis of NAND Flash Driver in Embedded Linux

I. Description of the source code file of the NAND Flash Driver

In the Linux kernel, The MTD source code is stored in the/driver/MTD Directory, which contains six subdirectories: chips, devices, maps, Nand, onenand, and ubi. Only the code in the NAND and onenand directories is related to the NAND driver. The code in the NAND directory is more common, and the code in the onenand directory is much simpler than the code in the NAND directory, it is an alternative NAND Flash developed by Samsung. The market share is not very high. Therefore, to develop an MTD-based NAND driver, you only need to pay attention to the NAND directory, including kconfig, makefile, and the following important files:

1. nand_base.c

Defines the most basic operation functions and procedures for the NAND chip in the NAND driver, such as erasure, read/write page, read/write OOB, and so on. It is the core file of the NAND driver.

2. nand_bbt.c

Defines functions and struct related to bad block management in the NAND drive.

3. nand_ids.c

Two global struct types are defined: struct nand_flash_dev nand_flash_ids [] and struct nand_manufacturers nand_manuf_ids []. The former defines some types of NAND chips, and the latter defines the information of several vendors of NAND chips. The three attributes of nand_flash_ids [] are important, namely pagesize, chipsize, and erasesize. The driver is the three attributes used for data size operations such as erasure and read/write.

4. nand_ecc.c

Defines functions and struct related to softwareecc In the NAND drive.

5. nandsim, c

A simulated NAND device developed by Nokia is defined. The default value is toshba NAND 8 Mb.

6. diskonchip. c

Defines functions related to disks on a chip, so you don't have to worry about developing a common NAND Flash Driver.

7. S3C2410. c

For the S3C2440 system NAND Flash Driver instance, we need to port the NAND Flash Driver to different CPUs, mainly to implement the NAND Flash Driver source code file.

 

Ii. NAND flash drive Architecture

(1) NAND Flash Platform equipment mainly involves the file is dev-nand.c

 

Register the NAND Flash Platform device is implemented in mach-mini2440.c:

Static void _ init mini2440_machine_init (void)
{
# If defined (LCD _width)
S3c24xx_fb_set_platdata (& mini2440_fb_info );
# Endif
Initi_i2c0_set_platdata (null );

S3c2410_gpio_cfgpin (s3c2410_gpc (0), s3c2410_gpc0_lend );

// Set private data of the NAND Flash Platform DeviceFriendly_arm_nand_info,

Initi_device_nand.dev.platform_data = & friendly_arm_nand_info;
Initi_device_sdi.dev.platform_data = & mini2440_mmc_cfg;

// Register the platform device to the kernel's platform bus. The platform_device_register () function is also implemented through platform_add_devices,
Platform_add_devices (mini2440_devices, array_size (mini2440_devices ));
Initi_pm_init ();
}

The struct s3c2410_platform_nandFriendly_arm_nand_infoIs:

Static struct s3c2410_platform_nand friendly_arm_nand_info = {
. Tacls = 20,
. Twrph0 = 60,
. Twrph1 = 20,
. Nr_sets = array_size (friendly_arm_nand_sets ),
. Sets = friendly_arm_nand_sets,
. Ignore_unset_ecc = 1,
};
(2) The driver of the NAND Flash Platform is mainly related to the S3C2410. c file.

Static struct platform_driverS3c24xx_nand_driver= {
. Probe = s3c24xx_nand_probe,
. Remove = s3c24xx_nand_remove,
. Suspend = s3c24xx_nand_suspend,
. Resume = s3c24xx_nand_resume,
. Id_table = s3c24xx_driver_ids,
. Driver = {
. Name = "s3c24xx-nand ",
. Owner = this_module,
},
};

Static int _ init s3c2410_nand_init (void)
{
Printk ("s3c24xx NAND driver, (c) 2004 simtec electronics \ n ");

Return platform_driver_register (& s3c24xx_nand_driver );
}

Static void _ exit s3c2410_nand_exit (void)
{
Platform_driver_unregister (& s3c24xx_nand_driver );
}

Module_init (s3c2410_nand_init );
Module_exit (s3c2410_nand_exit );

In the embedded Linux operating system, the development of platform device drivers is divided into the following three steps:

(1) Define and initialize the platform device driver struct variable struct platform_driver s3c24xx_nand_driver of the platform device.

(2) register the driver struct variable struct platform_driver s3c24xx_nand_driver of the platform device to the kernel.

(3) Implement the membership function in the struct variable struct platform_driver s3c24xx_nand_driver of the platform device driver.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.