From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aiMQl-0001kg-SR for linux-mtd@lists.infradead.org; Tue, 22 Mar 2016 13:33:09 +0000 Received: by mail-qg0-x235.google.com with SMTP id w104so178031730qge.1 for ; Tue, 22 Mar 2016 06:32:46 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge.ramirez-ortiz@linaro.org, dwmw2@infradead.org, computersforpeace@gmail.com, matthias.bgg@gmail.com, robh@kernel.org, boris.brezillon@free-electrons.com Cc: linux-mtd@lists.infradead.org, xiaolei.li@mediatek.com, daniel.thompson@linaro.org, erin.lo@mediatek.com, linux-mediatek@lists.infradead.org Subject: [RFCv2 0/2] MTK Smart Device Gen1 NAND Driver Date: Tue, 22 Mar 2016 09:32:38 -0400 Message-Id: <1458653560-2679-1-git-send-email-jorge.ramirez-ortiz@linaro.org> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Fixes/Changes on v2 relative to: -------------------------------- tree : https://github.com/bbrezillon/linux-0day branch : nand/ecclayout commit : commit eafabf3b93f5ba796081d1beab3b9ed0dea40a9a Author: Boris Brezillon Date: Thu Feb 4 10:16:18 2016 +0100 mtd: kill the nand_ecclayout struct RFC v2: ------- mtd: mediatek: device tree docs for MTK Smart Device Gen1 NAND - split nand flash interface and ecc engine mtd: mediatek: driver for MTK Smart Device Gen1 NAND - split host and ecc in two separate drivers. - expose ecc layout through mtd_ooblayout_ops. - fix wait loops. - use device tree to describe ecc strength and ecc size. - use device tree to describe CS. - replace cmdfunc with cmd_ctrl. - fix read byte interface. dont enable controller in mt2701.dtsi - requires additional device tree changes. This will be done in the near future. Overview: ========= The following patch-set adds support for Mediatek's Smart Device Gen1 NAND controller. The MTK controller generates ECC parity data for both the sector data and the 8B FDM data associated to that sector. * Controller expected layout: ----------------------------- The controller expects the OOB information relevant to each sector within the page to follow immediately the data field. For example for a 4KiB page with 1KiB sectors and 128B of OOB information, the controller would expect the following layout. ----------------------------------------------------- | 1KiB | 32B | 1KiB | 32B | 1KiB | 32B | 1KiB | 32B | ----------------------------------------------------- This implies that the following actions are required: - raw writes: to match the controller expected layout, the driver uses the CPU and a private bounce buffer to reassemble the page before the actual writes. - non raw writes: ecc is hardware generated and data DMA'd in a single transfer. the driver uses the CPU to copy the OOB information for each sector to its associated FDM register (4B FDM_L, 4B FDM_H) before initiating the DMA. * Bad block mark position: -------------------------- The bad block mark position is generated at some offset within the sector data area. To work around this, the driver includes the function mtk_nfc_switch_oob so it can initialize the BBT during probe. Similarly, when marking a block as bad, the driver will fill the whole page with 0x00 (it would be meaningless for this controller to write the watermark to the OOB area). Controller limitations: ======================= * dma chaning not supported: To guarantee that the pages corresponding to the buffers are contiguous in memory we enabled NAND_USE_BOUNCE_BUFFER. Tests: ====== * UBIFS support has been validated on 512MiB device (iozone, dd) * All drivers/mtd/tests/* pass clean. * Speed tests: - eraseblock write speed : 7451 KiB/s - eraseblock read speed : 10817 KiB/s - page write speed : 7250 KiB/s - page read speed : 10792 KiB/s - 2 page write speed : 7350 KiB/s - 2 page read speed : 10802 KiB/s - erase speed : 105215 KiB/s - 2x multi-block erase speed : 354728 KiB/s - 4x multi-block erase speed : 356658 KiB/s - 8x multi-block erase speed : 357631 KiB/s - 16x multi-block erase speed : 358365 KiB/s - 32x multi-block erase speed : 358365 KiB/s - 64x multi-block erase speed : 358610 KiB/s Jorge Ramirez-Ortiz (2): mtd: mediatek: device tree docs for MTK Smart Device Gen1 NAND mtd: mediatek: driver for MTK Smart Device Gen1 NAND .../devicetree/bindings/mtd/mtksdg1-nand.txt | 143 +++ drivers/mtd/nand/Kconfig | 7 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/mtksdg1_ecc.c | 446 +++++++ drivers/mtd/nand/mtksdg1_ecc.h | 62 + drivers/mtd/nand/mtksdg1_ecc_regs.h | 76 ++ drivers/mtd/nand/mtksdg1_nand.c | 1225 ++++++++++++++++++++ drivers/mtd/nand/mtksdg1_nfi_regs.h | 121 ++ 8 files changed, 2081 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/mtksdg1-nand.txt create mode 100644 drivers/mtd/nand/mtksdg1_ecc.c create mode 100644 drivers/mtd/nand/mtksdg1_ecc.h create mode 100644 drivers/mtd/nand/mtksdg1_ecc_regs.h create mode 100644 drivers/mtd/nand/mtksdg1_nand.c create mode 100644 drivers/mtd/nand/mtksdg1_nfi_regs.h -- 2.5.0