Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux nand flash driver programming

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

For a long time, nand flash has been a standard embedded product. Nand flash is cheap and has a large storage capacity, so it is suitable for many scenarios. Now very popular ssd, the storage module above is actually made up of a piece of nand flash. For linux embedded, the initial uboot loading is completed by hardware, the middle kernel loading is completed by the nand flash driver in uboot, and the later rootfs loading is completed by kernel itself. Of course, this time we will take the Samsung S3c chip as an example.

1. Where is the nand flash driver? you can see it from drviers/mtd/Makefile.

Obj-y + = chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/

2. Nand is under mtd and is saved as a separate directory. You should check the Kconfig under nand.

Config MTD_NAND_S3C2410 tristate "NAND Flash support for Samsung S3C SoCs" depends on ARCH_S3C24XX | | ARCH_S3C64XX help This enables the NAND flash controller on the S3C24xx and S3C64xx SoCs No board specific support is done by this driver, each board must advertise a platform_device for the driver to attach. Config MTD_NAND_S3C2410_DEBUG bool "Samsung S3C NAND driver debug" depends on MTD_NAND_S3C2410 help Enable debugging of the S3C NAND driver config MTD_NAND_S3C2410_CLKSTOP bool "Samsung S3C NAND IDLE clock stop" depends on MTD_NAND_S3C2410 default n help Stop the clock to the NAND controller when there is no chip selected to save power. This will mean there is a small delay when the is NAND chip selected or released, but will save approximately 5mA of power when there is nothing happening.

3. It is not difficult to find that MTD_NAND_S3C2410 is the real macro. Try to find files in Makefile.

Obj-$ (CONFIG_MTD_NAND_S3C2410) + = s3c2410.o

4. Check the s3c2410.c file to see the basic structure

Static struct platform_driver s3c24xx_nand_driver = {.probe = s3c24xx_nand_probe, .remove = s3c24xx_nand_remove, .probe = s3c24xx_nand_suspend, .probe = s3c24xx_nand_resume, .id _ table = s3c24xx_driver_ids, .driver = {.name = "s3c24xx-nand", .of _ match_table = s3c24xx_nand_dt_ids,},}; module_platform_driver (s3c24xx_nand_driver)

5. Continue to analyze the s3c24xx_nand_probe function

S3c2410_nand_init_chip (info, nmtd, sets)

6. The function s3c2410_nand_init_chip is extracted from it because the function is registered in it.

Similar functions also have s3c2410_nand_update_chip functions.

Chip- > write_buf = s3c2410roomnandwritten writebread buf; chip- > read_buf = s3c2410roomnandchocolate readreadbug buf; chip- > select_chip = s3c2410roomnandchocolate selectchips; chip- > chip_delay = 50; nand_set_controller_data (chip, nmtd); chip- > options = set- > options; chip- > controller = & info- > controller; switch (info- > cpu_type) {case TYPE_S3C2410: chip- > IO_ADDR_W = regs + S3C2410nm NFDATA; info- > sel_reg = regs + S3C2410_NFCONF Info- > sel_bit = S3C2410NFCONFCONTnFCER; chip- > cmd_ctrl = s3c2410roomnandroomhwcontrol; chip- > dev_ready = s3c2410devready; break; case TYPE_S3C2440: chip- > IO_ADDR_W = regs + S3C2440NFDATA; info- > sel_reg = regs + S3C2440NFCONTS; info- > sel_bit = S3C2440nm NFCONTCONTnFCES; chip- > cmd_ctrl = s3c2440roomnandroomhwcontrol; chip- > dev_ready = s3c2440roomnanddevready; chip- > read_buf = s3c2440_nand_read_buf Chip- > write_buf = s3c2440roomnandwriting writecontrol buf; break; case TYPE_S3C2412: chip- > IO_ADDR_W = regs + S3C2440roomNFDATA; info- > sel_reg = regs + S3C2440roomNFCONTNFCE0; info- > sel_bit = S3C2412roomNFCONTCONTFCE0; chip- > cmd_ctrl = s3c2440roomnandroomhwcontrol; chip- > dev_ready = s3c2412roomnanddevready; if (readl (regs + S3C2410_NFCONF) & S3C2412_NFCONF_NANDBOOT) dev_info (info- > device, "System booted from NAND\ n") Break;}

7. if you grasp the function interface, you will find the basic logic.

For the framework, it doesn't care how your code is implemented. As long as you write according to its interface, you can make the upper layer get the data normally. Platform, usb and pci are all interface forms, and the specific implementation should be implemented according to each specific functional module.

8. Why do we all use S3C chip as an example

Because it uses the most scenes and the most complete learning materials, it will be a lot less trouble for beginners.

9. What is the kernel version on which this driver depends

Most of the codes here are analyzed according to the latest version 4.16, you can check the address here directly.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report