Updating nand flash driver from linux kernel 4.14 to 4.19

From ElphelWiki
Revision as of 12:08, 26 September 2019 by Oleg (talk | contribs) (NAND FLASH chip)
Jump to: navigation, search

About

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:

xlnx_rebase_v4.14
xlnx_rebase_v4.19  

NAND FLASH chip

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

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

Notes

That minor change is to set ops.mode to MTD_OPS_RAW instead of normal. Hooks for normal ops
can enable/disable ECC features which will reset OTP mode (which is also a feature set)
  • 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.