Difference between revisions of "Updating nand flash driver from linux kernel 4.14 to 4.19"

From ElphelWiki
Jump to: navigation, search
(Created page with "==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 k...")
 
(Updating to 4.19)
 
(4 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
* ON-DIE ECC feature supported - they call it internal ECC in the datasheet:
 
* 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
 
  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==
 
==Linux Kernel 4.14 and older==
Line 20: Line 19:
 
* A lot has changed since 4.14
 
* A lot has changed since 4.14
 
** new ''->exec_op'' hook vs old ''->cmdfunc''
 
** new ''->exec_op'' hook vs old ''->cmdfunc''
 +
** Xilinx tries to keep up with their driver - they might have tested this on [https://lwn.net/Articles/756725/ Micron MT29F2G08ABAEAWP (On-die capable) and AMD/Spansion S34ML01G1]
 
* OTP function are not supported yet, and need a minor change to make them more universal
 
* OTP function are not supported yet, and need a minor change to make them more universal
* Old LOCK/UNLOCK function need to be updated to the new codebase
+
That minor change is to set ops.mode to MTD_OPS_RAW instead of normal. Hooks for normal ops
* Set ''nand-ecc-mode = "on-die";'' in the device tree.
+
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
 
* Add NAND_NO_SUBPAGE_WRITE to chip->options for MT29F8G08ADBDAH4
===Results===
+
Otherwise driver goes for subpage program support. '''Need to test this.'''
 +
 
 +
===Driver code===
 
See the code here:
 
See the code here:
 
* [https://git.elphel.com/Elphel/linux-elphel/blob/warrior/src/arch/arm/boot/dts/elphel393-zynq-base.dtsi#L299 device tree]
 
* [https://git.elphel.com/Elphel/linux-elphel/blob/warrior/src/arch/arm/boot/dts/elphel393-zynq-base.dtsi#L299 device tree]
  Those ''arm,nand-cycle-t0-6'' can be removed
+
  Those ''arm,nand-cycle-t0-6'' are obsolete and can be removed from DT.
 
* [https://git.elphel.com/Elphel/linux-elphel/tree/d4f217cf68d8c3c9a84f680dd014b1a0de0571c8/src/drivers/mtd/nand/raw driver code]
 
* [https://git.elphel.com/Elphel/linux-elphel/tree/d4f217cf68d8c3c9a84f680dd014b1a0de0571c8/src/drivers/mtd/nand/raw driver code]
  Didn't make a patch - the changes are for a specific MT29F8G08ADBDAH4. Although they might work for others as well we have only tested the chip we use.
+
  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.

Latest revision as of 13:10, 26 September 2019

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. Need to test this.

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.