Driver Analysis of S3C2440 NAND FLASH Migration to S3C2410

Publisher:EternalSunsetLatest update time:2024-06-11 Source: elecfansKeywords:S3C2440  NAND  FLASH  S3C2410 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There are some differences between the NAND FLASH driver of S3C2440A and S3C2410. The main difference is that the NAND FLASH registers of these two ICs are slightly different. Please see the difference between the two below:

  1. //

  2. // Copyright (c) Microsoft Corporation. All rights reserved.

  3. //

  4. //

  5. // Use of this source code is subject to the terms of the Microsoft end-user

  6. // license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.

  7. // If you did not accept the terms of the EULA, you are not authorized to use

  8. // this source code. For a copy of the EULA, please see the LICENSE.RTF on your

  9. // install media.

  10. //

  11. //------------------------------------------------ ----------------------------------

  12. //

  13. // Header: s3c2410x_nand.h

  14. //

  15. // Defines the NAND controller CPU register layout and definitions.

  16. //

  17. #ifndef __S3C2410X_NAND_H

  18. #define __S3C2410X_NAND_H

  19. #if __cplusplus

  20. extern "C"

  21. {

  22. #endif

  23. //------------------------------------------------ ----------------------------------

  24. // Type: S3C2410X_NAND_REG

  25. //

  26. // NAND Flash controller register layout. This register bank is located

  27. // by the constant CPU_BASE_REG_XX_NAND in the configuration file

  28. // cpu_base_reg_cfg.h.

  29. //

  30. typedef struct

  31. {

  32. UINT32 NFCONF; // configuration reg

  33. UINT8 NFCMD; // command set reg

  34. UINT8 pad1[3]; // pad

  35. UINT8 NFADDR; // address set reg

  36. UINT8 pad2[3]; // pad

  37. UINT8 NFDATA; // data reg

  38. UINT8 pad3[3]; // pad

  39. UINT32 NFSTAT; // operation status reg

  40. UINT32 NFECC; // error correction code 0

  41. } S3C2410X_NAND_REG, *PS3C2410X_NAND_REG;

  42. #if __cplusplus

  43. }

  44. #endif

  45. #endif

The above code is the register of S3C2410A. Let's take a look at the register address description of S3C2440A:

  1. //

  2. // Copyright (c) Microsoft Corporation. All rights reserved.

  3. //

  4. //

  5. // Use of this source code is subject to the terms of the Microsoft end-user

  6. // license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.

  7. // If you did not accept the terms of the EULA, you are not authorized to use

  8. // this source code. For a copy of the EULA, please see the LICENSE.RTF on your

  9. // install media.

  10. //

  11. //------------------------------------------------ ----------------------------------

  12. //

  13. // Header: s3c2440a_nand.h

  14. //

  15. // Defines the NAND controller CPU register layout and definitions.

  16. //

  17. #ifndef __S3C2440A_NAND_H

  18. #define __S3C2440A_NAND_H

  19. #if __cplusplus

  20. extern "C"

  21. {

  22. #endif

  23. //------------------------------------------------ ----------------------------------

  24. // Type: S3C2440A_NAND_REG

  25. //

  26. // NAND Flash controller register layout. This register bank is located

  27. // by the constant CPU_BASE_REG_XX_NAND in the configuration file

  28. // cpu_base_reg_cfg.h.

  29. //

  30. typedef struct

  31. {

  32. UINT32 NFCONF; // configuration reg

  33. UINT32 NFCONT;

  34. UINT8 NFCMD; // command set reg

  35. UINT8 d0[3];

  36. UINT8 NFADDR; // address set reg

  37. UINT8 d1[3];

  38. UINT8 NFDATA; // data reg

  39. UINT8 d2[3];

  40. UINT32 NFMECCD0;

  41. UINT32 NFMECCD1;

  42. UINT32 NFSECCD;

  43. UINT32 NFSTAT; // operation status reg

  44. UINT32 NFESTAT0;

  45. UINT32 NFESTAT1;

  46. UINT32 NFMECC0; // error correction code 0

  47. UINT32 NFMECC1; // error correction code 1

  48. UINT32 NFSECC;

  49. UINT32 NFSBLK;

  50. UINT32 NFEBLK; // error correction code 2

  51. } S3C2440A_NAND_REG, *PS3C2440A_NAND_REG;

  52. #if __cplusplus

  53. }

  54. #endif

  55. #endif

The difference between the two is huge. Therefore, the difficulty in transplantation is mainly the ECC part. At the same time, the addresses of some register bits are different and need to be modified, as shown below:

  1. // Use Macros here to avoid extra over head for c function calls

  2. #define READ_REGISTER_BYTE(p) (*(PBYTE)(p))

  3. #define WRITE_REGISTER_BYTE(p, v) (*(PBYTE)(p)) = (v)

  4. #define READ_REGISTER_USHORT(p) (*(PUSHORT)(p))

  5. #define WRITE_REGISTER_USHORT(p, v) (*(PUSHORT)(p)) = (v)

  6. #define READ_REGISTER_ULONG(p) (*(PULONG)(p))

  7. #define WRITE_REGISTER_ULONG(p, v) (*(PULONG)(p)) = (v)

The above code can be used for both S3C2410 and S3C2440. When I transplanted them, the two parts were the same. Of course, the registers of S3C2443 and S3C2450 have not changed much, but the NAND FLASH driver in the BSP of S3C2450 has changed a lot. I will analyze it later. Now I will analyze this under WINCE5.0. I haven't had time to transplant WINCE6.0 yet. I usually like to transplant it myself, so that I can have a deeper understanding of the WINCE process and become more familiar with this IC. Let's take a look at the difference between the two.


Register macro definition of S3C2440A:

  1. //MACROS

  2. #define NF_CE_L() WRITE_REGISTER_USHORT(pNFCONT, (USHORT) (READ_REGISTER_USHORT(pNFCONT) & ~(1<<1)))

  3. #define NF_CE_H() WRITE_REGISTER_USHORT(pNFCONT, (USHORT) (READ_REGISTER_USHORT(pNFCONT) | (1<<1)))

  4. #define NF_CMD(cmd) WRITE_REGISTER_USHORT(pNFCMD, (USHORT) (cmd))

  5. #define NF_ADDR(addr) WRITE_REGISTER_USHORT(pNFADDR, (USHORT) (addr))

  6. #define NF_DATA_R() READ_REGISTER_BYTE(pNFDATA)

  7. #define NF_DATA_W(val) WRITE_REGISTER_BYTE(pNFDATA, (BYTE) (val))

  8. #define NF_DATA_R4() READ_REGISTER_ULONG(pNFDATA)

  9. #define NF_DATA_W4(val) WRITE_REGISTER_ULONG(pNFDATA, (ULONG) (val))

  10. #define NF_STAT() READ_REGISTER_USHORT(pNFSTAT)

  11. #define NF_MECC_UnLock() WRITE_REGISTER_USHORT(pNFCONT, (USHORT) (READ_REGISTER_USHORT(pNFCONT) & ~(1<<5)))

  12. #define NF_MECC_Lock() WRITE_REGISTER_USHORT(pNFCONT, (USHORT) (READ_REGISTER_USHORT(pNFCONT) | (1<<5)))

  13. #define NF_RSTECC() WRITE_REGISTER_USHORT(pNFCONT, (USHORT) (READ_REGISTER_USHORT(pNFCONT) | (1<<4)))

  14. #define NF_WAITRB() {while(!(NF_STAT() & ​​(1<<1))) ;}

  15. #define NF_CLEAR_RB() WRITE_REGISTER_USHORT(pNFSTAT, (USHORT) (READ_REGISTER_USHORT(pNFSTAT) | (1<<2)))

  16. #define NF_DETECT_RB() {while(!(NF_STAT() & ​​(1<<2)));}

  17. #define NF_ECC() READ_REGISTER_ULONG(pNFECC)

Register macro definition of S3C2410A:

  1. //MACROS

  2. #define NF_CE_L() WRITE_REGISTER_USHORT(pNFCONF, (USHORT) (READ_REGISTER_USHORT(pNFCONF) & ~(1 << 11)))

  3. #define NF_CE_H() WRITE_REGISTER_USHORT(pNFCONF, (USHORT) (READ_REGISTER_USHORT(pNFCONF) | (1 << 11)))

  4. #define NF_CMD(cmd) WRITE_REGISTER_USHORT(pNFCMD, (USHORT) (cmd))

  5. #define NF_ADDR(addr) WRITE_REGISTER_USHORT(pNFADDR, (USHORT) (addr))

  6. #define NF_DATA_R() READ_REGISTER_USHORT(pNFDATA)

  7. #define NF_DATA_W(val) WRITE_REGISTER_BYTE(pNFDATA, (BYTE)(val))

  8. #define NF_STAT() READ_REGISTER_USHORT(pNFSTAT)

  9. #define NF_RSTECC() WRITE_REGISTER_USHORT(pNFCONF, (USHORT) (READ_REGISTER_USHORT(pNFCONF) | (1 << 12)))

  10. #define NF_WAITRB() {while(!(NF_STAT() & ​​(1<<0))) ;}

  11. #define NF_DETECT_RB() {while(!(NF_STAT() & ​​0x01));}

  12. #define NF_ECC() READ_REGISTER_ULONG(pNFECC)

The registers of S3C2410 are the register definitions that I have modified. The main differences are: NF_CE_L(), NF_CE_H(), NF_RSTECC(), NF_WAITRB(), NF_DETECT_RB(). These registers can be distinguished by the detailed descriptions on the datasheets of the two. I will not explain them in detail here! Modifying the registers is the first and most important step in porting the NAND FLASH driver.


Keywords:S3C2440  NAND  FLASH  S3C2410 Reference address:Driver Analysis of S3C2440 NAND FLASH Migration to S3C2410

Previous article:ADC driver implementation for ARM Linux S3C2440
Next article:S3C2440 Hardware Programming Example

Recommended ReadingLatest update time:2024-11-16 09:24

uboot-2011.12 ported to S3C2440 (Part 1) - Simple modification to enable u-boot to compile
The cross-compilation environment is a cross-compilation toolchain made by Fedora14 and Friendly Arm 1. Modify boards.cfg and add a red line         smdk2400 arm arm920t - samsung s3c24x0         smdk2410 arm arm920t - samsung s3c24x0         smdk2440 arm arm920t - samsung s3c24x0 2. Under $(SOURCEDIR)/u-boot-20
[Microcontroller]
Things about S3C2440’s interrupts (2) C language part explained
 1 void init_irq( )  2 {  3 //Set the two pins corresponding to S2 and S3 as interrupt pins EINT0 and ENT2  4 GPFCON &= ~(GPF0_msk | GPF2_msk);  5 GPFCON |= GPF0_eint | GPF2_eint;  6   7 //The pin corresponding to S4 is set as the interrupt pin EINT11  8 GPGCON &= ~GPG3_msk;  9 GPGCON |= GPG3_eint; 10      11 // For E
[Microcontroller]
Read and write data between STM32 and Flash AT45DB321D
To debug a chip like Flash, you must first read out its ID before you can perform read and write operations. AT45DB321D 8192pages (512/528Bytes/Pages) is about 4M, and communicates with the microcontroller via SPI. The general process is to configure spi first, read the chip ID, write a data into the flash and the
[Microcontroller]
Read and write data between STM32 and Flash AT45DB321D
NEO Semiconductor Launches X-NAND Technology to Replace Traditional NAND
Traditional NAND often faces inefficiencies in power, performance and cost. NEO Semiconductor announced that it has recently obtained some patents in the field of X-NAND that can overcome these limitations. Since NAND was commercialized and mass-produced in the early 1990s, developers have been looking fo
[Embedded]
NEO Semiconductor Launches X-NAND Technology to Replace Traditional NAND
s3c2440 bare metal - code relocation -1- introduction of relocation
1. Introduction of relocation (why code relocation is needed) We know that the CPU of s3c2440 starts to fetch instructions from address 0. When it is started from nor, address 0 corresponds to nor. nor can be read like memory, but cannot be written like memory. We can fetch instructions from nor. Exa
[Microcontroller]
1.9.4_ADC and touch screen_S3C2440 touch screen interface_P
From the previous section, we know that the detection of touch screen presses and the calculation of touch point coordinates are accomplished through the five switches S1 to S5. By controlling the opening and closing of the five switches at different times, the XY coordinates of the touch point can be obtained. Chec
[Microcontroller]
1.9.4_ADC and touch screen_S3C2440 touch screen interface_P
S3C2440 development board bare metal program series 01--Flowing light
Platform introduction: TQ2440 development board, NorFlash 2M, NandFlash 521M (K9F4G08U0B), 2 32MSDRAM (H57V2562GTR-60C) The purpose of this series is to record the bare metal programming process of TQ2440, and take mini2440 into consideration. This article contains: 1. Introduction to GPIO key points; 2. TQ2440 ru
[Microcontroller]
S3C2440 development board bare metal program series 01--Flowing light
ARM Linux S3C2440 Interrupt Analysis
Hardware: S3C2440 is an arm920T architecture. Let's first review the interrupt controller principles and related hardware architecture in s3c2440. Interrupt Controller: The interrupt controller of S3c2440A has 60 interrupt sources, such as DMA interrupt, UART interrupt, IIC interrupt, etc. The 60 inte
[Microcontroller]
ARM Linux S3C2440 Interrupt Analysis
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号