Updating nand flash driver from linux kernel 4.14 to 4.19

From ElphelWiki
Revision as of 11:38, 26 September 2019 by Oleg (talk | contribs) (Updating to 4.19)
Jump to: navigation, search


Below are the changes had to be made to update our nand flash driver code from kernel 4.14 to 4.19. The kernel versions mentioned are the rebases from the mainline kernel in linux-xlnx repo with xilinx's code:



Micron MT29F8G08ADBDAH4:

  • ON-DIE ECC feature supported - they call it internal ECC in the datasheet:
Internal ECC enables 5-bit detection and 4-bit error correction in 512 bytes
  • Subpage (or partial) writes are not supported.

Linux Kernel 4.14 and older

Until 4.14 (including) our driver code additions worked unchanged. We basically needed a couple of things:

  • LOCK/UNLOCK functions (which were removed in 4.14). The code existed in up to 4.13 release - so it was just taken from there.
  • Function to work with the chip's (MT29F8G08ADBDAH4) OTP area. The original code was taken from here

Updating to 4.19


  • A lot has changed since 4.14
    • new ->exec_op hook vs old ->cmdfunc
    • Xilinx tries to keep up with their driver
  • OTP function are not supported yet, and need a minor change to make them more universal
  • Old LOCK/UNLOCK functions from pre 4.14 kernel need to be updated to the new codebase
Those op_parser patterns. 
Also UNLOCK command is 2 parts: 0x23 BOUND_LO 0x24 BOUND_HI - so, before 0x24 has to be some sort of a delay or the op should be split into 2.
Datasheet does not provide any timing info
  • Set nand-ecc-mode = "on-die"; in the device tree.
In 4.14 it used to be detected as "on-die", but not anymore.
  • Add NAND_NO_SUBPAGE_WRITE to chip->options for MT29F8G08ADBDAH4
Otherwise driver goes for subpage program support

Driver code

See the code here:

Those arm,nand-cycle-t0-6 are obsolete and can be removed from DT.
Didn't make a patch - the changes are for a specific MT29F8G08ADBDAH4. Although they might work for other chips as well we have only tested the one we use.