support gpmi on i.MX6UL/7D and HW bitflip on i.MX6QP/7D
Subsystems (3)
v3 cover support gpmi on i.MX6UL/7D and HW bitflip on i.MX6QP/7D
add support for gpmi nand on i.MX6UL and i.MX7D, document the related properties in DT and add the HW bitflip detection and correction for i.MX6QP and i.MX7D.
v1 ---> v2:
fix several indent and open parenthesis issues drop off the void cast
rebase to latest code and adopt to SW bitflip code split bitflip and i.MX6QP code
v2 ---> v3:
calculate erased chunks and fix bitflip after loop add more details for i.MX7 clock name
fix the patch name for documentation
Han Xu (6):
mtd: nand: gpmi: add GPMI NAND support for i.MX7D
Documentation: dt: mtd: gpmi: document the clocks and clock-names in
DT property
mtd: nand: gpmi: add GPMI NAND support for i.MX6QP
mtd: nand: gpmi: correct bitflip for erased NAND page
mtd: nand: gpmi: support NAND on i.MX6UL
Documentation: dt: mtd: gpmi: document the new supported chip in DT
.../devicetree/bindings/mtd/gpmi-nand.txt | 12 ++- drivers/mtd/nand/gpmi-nand/bch-regs.h | 24 ++++-- drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 15 +++- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 85 +++++++++++++++++++--- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 15 +++- 5 files changed, 127 insertions(+), 24 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 2/6 Documentation: dt: mtd: gpmi: document the clocks and clock-names in DT property
add the clocks and clock-names in DT property, gpmi-io clock is mandatory for all platforms, but some platforms, such as i.MX6Q may need more extra clocks for submodules. More details please refer to the SoC reference manual.
--- Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +9 -0
@@ -13,6 +13,13 @@ Required properties: and GPMI DMA channel ID. Refer to dma.txt and fsl-mxs-dma.txt for details. - dma-names: Must be "rx-tx". + - clocks : The clocks needed by the gpmi controller. This field varies + depends on the SoC design, "gpmi-io" is mandatory but some platforms may + need several extra clocks, such as i.MX6 series, which requires "gpmi_apb, + gpmi_bch, gpmi_bch_apb and per1_bch" for all submodules, while i.MX7 only + need gpmi_bch_apb. Please refer to the HW design manual. + - clock-names : the name of the clocks, please refer to the HW design + manual. Optional properties: - nand-on-flash-bbt: boolean to enable on flash bbt option if not
@@ -51,6 +58,8 @@ gpmi-nand@8000c000 { interrupt-names = "bch"; dmas = <&dma_apbh 4>; dma-names = "rx-tx"; + clocks = <&clks 50>,; + clock-names = "gpmi_io"; partition@0 { ...
Signature · 1 line
1.9.1
PATCH v3 3/6 mtd: nand: gpmi: add GPMI NAND support for i.MX6QP
In reply to Han Xusupport GPMI NAND on i.MX6QP
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 9 +++++++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +9 -0
@@ -104,6 +104,12 @@ static const struct gpmi_devdata gpmi_devdata_imx6q = { .max_chain_delay = 12, }; +static const struct gpmi_devdata gpmi_devdata_imx6qp = { + .type =IS_MX6QP , + .bch_max_ecc_strength =40 , + .max_chain_delay =12 , +}; +static const struct gpmi_devdata gpmi_devdata_imx6sx = { .type =IS_MX6SX , .bch_max_ecc_strength =62 ,
@@ -2086,6 +2092,9 @@ static const struct of_device_id gpmi_nand_id_table[] = { .compatible = "fsl,imx6q-gpmi-nand", .data = &gpmi_devdata_imx6q, }, { + .compatible = "fsl,imx6qp-gpmi-nand", + .data = &gpmi_devdata_imx6qp, + }, { .compatible = "fsl,imx6sx-gpmi-nand", .data = &gpmi_devdata_imx6sx, }, {
drivers/mtd/nand/gpmi-nand/gpmi-nand.h +4 -1
@@ -123,6 +123,7 @@ enum gpmi_type {IS_MX23 ,IS_MX28 ,IS_MX6Q , +IS_MX6QP ,IS_MX6SX , IS_MX7D, };
@@ -305,9 +306,11 @@ void gpmi_copy_bits(u8 *dst, size_t dst_bit_off,#define GPMI_IS_MX23 (x) ((x)->devdata->type == IS_MX23)#define GPMI_IS_MX28 (x) ((x)->devdata->type == IS_MX28)#define GPMI_IS_MX6Q (x) ((x)->devdata->type == IS_MX6Q) +#define GPMI_IS_MX6QP (x) ((x)->devdata->type == IS_MX6QP)#define GPMI_IS_MX6SX (x) ((x)->devdata->type == IS_MX6SX)#define GPMI_IS_MX7D (x) ((x)->devdata->type == IS_MX7D) -#define GPMI_IS_MX6 (x) (GPMI_IS_MX6Q(x) || GPMI_IS_MX6SX(x)) +#define GPMI_IS_MX6 (x) (GPMI_IS_MX6Q(x) || GPMI_IS_MX6QP(x) \ + || GPMI_IS_MX6SX(x))#define GPMI_IS_MX7 (x) (GPMI_IS_MX7D(x))#endif
Signature · 1 line
1.9.1
PATCH v3 4/6 mtd: nand: gpmi: correct bitflip for erased NAND page
In reply to Han Xui.MX6QP and i.MX7D BCH module integrated a new feature to detect the bitflip number for erased NAND page. So for these two platform, set the erase threshold to ecc_strength and if bitflip detected, GPMI driver will correct the data to all 0xFF.
--- drivers/mtd/nand/gpmi-nand/bch-regs.h | 10 +++++++++ drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 5 +++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 37 +++++++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-)
drivers/mtd/nand/gpmi-nand/bch-regs.h +10 -0
@@ -30,7 +30,13 @@#define BM_BCH_CTRL_COMPLETE_IRQ (1 << 0)#define HW_BCH_STATUS0 0x00000010 +#define HW_BCH_MODE 0x00000020 +#define BP_BCH_MODE_ERASE_THRESHOLD 0 +#define BM_BCH_MODE_ERASE_THRESHOLD (0xff << BP_BCH_MODE_ERASE_THRESHOLD) +#define BF_BCH_MODE_ERASE_THRESHOLD (v) \ + (((v) << BP_BCH_MODE_ERASE_THRESHOLD) & BM_BCH_MODE_ERASE_THRESHOLD) +#define HW_BCH_ENCODEPTR 0x00000030#define HW_BCH_DATAPTR 0x00000040#define HW_BCH_METAPTR 0x00000050
@@ -125,4 +131,8 @@ )#define HW_BCH_VERSION 0x00000160 +#define HW_BCH_DEBUG1 0x00000170 +#define BP_BCH_DEBUG1_ERASED_ZERO_COUNT 0 +#define BM_BCH_DEBUG1_ERASED_ZERO_COUNT \ + (0x1ff << BP_BCH_DEBUG1_ERASED_ZERO_COUNT)#endif
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +5 -0
@@ -298,6 +298,11 @@ int bch_set_geometry(struct gpmi_nand_data *this) | BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this), r->bch_regs + HW_BCH_FLASH0LAYOUT1); +/* Set erase threshold to ecc_strength for mx6qp and mx7 */ +if (GPMI_IS_MX6QP (this) ||GPMI_IS_MX7 (this)) +writel (BF_BCH_MODE_ERASE_THRESHOLD (ecc_strength), + r->bch_regs +HW_BCH_MODE ); +/* Set *all* chip selects to use layout 0. */ writel (0 , r->bch_regs +HW_BCH_LAYOUTSELECT );
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +34 -3
@@ -1043,11 +1043,12 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, {struct gpmi_nand_data *this =nand_get_controller_data (chip);struct bch_geometry *nfc_geo = &this->bch_geometry; +void __iomem *bch_regs = this->resources.bch_regs;void *payload_virt;dma_addr_t payload_phys;void *auxiliary_virt;dma_addr_t auxiliary_phys; -unsigned int i; +unsigned int i, j;unsigned char *status;unsigned int max_bitflips =0 ;int ret;
@@ -1087,9 +1088,14 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, nfc_geo->payload_size, payload_virt, payload_phys); -for (i =0 ; i < nfc_geo->ecc_chunk_count; i++, status++) { -if ((*status ==STATUS_GOOD ) || (*status ==STATUS_ERASED )) +for (i =0 , j =0 ; i < nfc_geo->ecc_chunk_count; i++, status++) { +if (*status ==STATUS_GOOD ) +continue ; +if (*status ==STATUS_ERASED ) { +/* count the number of erased chunks */ + j++;continue ; + }if (*status ==STATUS_UNCORRECTABLE ) {int eccbits = nfc_geo->ecc_strength * nfc_geo->gf_len;
@@ -1098,6 +1104,12 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,int eccbytes;int flips; +/* shortcut for i.MX7 and i.MX6QP */ +if (GPMI_IS_MX6QP (this) ||GPMI_IS_MX7 (this)) { + mtd->ecc_stats.failed++; +continue ; + } +/* Read ECC bytes into our internal raw_buffer */ offset = nfc_geo->metadata_size *8 ; offset += ((8 * nfc_geo->ecc_chunk_size) + eccbits) * (i +1 );
@@ -1167,6 +1179,25 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, max_bitflips = max_t(unsigned int, max_bitflips, *status); } +/* +* i.MX6QP and i.MX7 have dedicate register to check bitflips in the +* page, while it cannot tell in which chunk bitflips locate, memset +* all the data if bitflips exist and all chunks are erased. +*/ +if (j == nfc_geo->ecc_chunk_count && + (GPMI_IS_MX6QP (this) ||GPMI_IS_MX7 (this))) { +int flips; + + flips =readl (bch_regs +HW_BCH_DEBUG1 ); +if (flips) { + max_bitflips = max_t(unsigned int, max_bitflips, + flips); +memset (buf, ~0 , nfc_geo->payload_size); +memset (chip->oob_poi, ~0 , mtd->oobsize); + mtd->ecc_stats.corrected += flips; + } + } +if (oob_required) {/* * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob()
Signature · 1 line
1.9.1
PATCH v3 5/6 mtd: nand: gpmi: support NAND on i.MX6UL
In reply to Han Xusupport GPMI NAND on i.MX6UL
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 9 +++++++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +9 -0
@@ -122,6 +122,12 @@ static const struct gpmi_devdata gpmi_devdata_imx7d = { .max_chain_delay = 12, }; +static const struct gpmi_devdata gpmi_devdata_imx6ul = { + .type =IS_MX6UL , + .bch_max_ecc_strength =40 , + .max_chain_delay =12 , +}; +static irqreturn_t bch_irq (int irq,void *cookie) {struct gpmi_nand_data *this = cookie;
@@ -2129,6 +2135,9 @@ static const struct of_device_id gpmi_nand_id_table[] = { .compatible = "fsl,imx6sx-gpmi-nand", .data = &gpmi_devdata_imx6sx, }, { + .compatible = "fsl,imx6ul-gpmi-nand", + .data = &gpmi_devdata_imx6ul, + }, { .compatible = "fsl,imx7d-gpmi-nand", .data = &gpmi_devdata_imx7d, }, { /* sentinel */ }
drivers/mtd/nand/gpmi-nand/gpmi-nand.h +4 -1
@@ -126,6 +126,7 @@ enum gpmi_type {IS_MX6QP ,IS_MX6SX ,IS_MX7D , + IS_MX6UL, }; struct gpmi_devdata {
@@ -309,8 +310,10 @@ void gpmi_copy_bits(u8 *dst, size_t dst_bit_off,#define GPMI_IS_MX6QP (x) ((x)->devdata->type == IS_MX6QP)#define GPMI_IS_MX6SX (x) ((x)->devdata->type == IS_MX6SX)#define GPMI_IS_MX7D (x) ((x)->devdata->type == IS_MX7D) +#define GPMI_IS_MX6UL (x) ((x)->devdata->type == IS_MX6UL)#define GPMI_IS_MX6 (x) (GPMI_IS_MX6Q(x) || GPMI_IS_MX6QP(x) \ - || GPMI_IS_MX6SX(x)) + || GPMI_IS_MX6SX(x) || GPMI_IS_MX6UL(x)) +#define GPMI_IS_MX7 (x) (GPMI_IS_MX7D(x))#endif
Signature · 1 line
1.9.1
PATCH v3 6/6 Documentation: dt: mtd: gpmi: document the new supported chip in DT
In reply to Han Xulisted all supported chips in DT.
--- Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +2 -1
@@ -4,7 +4,8 @@ The GPMI nand controller provides an interface to control the NAND flash chips. Required properties: - - compatible : should be "fsl,<chip>-gpmi-nand" + - compatible : should be "fsl,<chip>-gpmi-nand", the chip should be imx23, + imx28, imx6q, imx6qp, imx6sx, imx6ul or imx7d. - reg : should contain registers location and length for gpmi and bch. - reg-names: Should contain the reg names "gpmi-nand" and "bch" - interrupts : BCH interrupt number.
Signature · 1 line
1.9.1
PATCH v3 1/6 mtd: nand: gpmi: add GPMI NAND support for i.MX7D
In reply to Han Xusupport GPMI NAND on i.MX7D
--- drivers/mtd/nand/gpmi-nand/bch-regs.h | 14 +++++++------- drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 10 ++++++---- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 30 ++++++++++++++++++++++++------ drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 7 +++++-- 4 files changed, 42 insertions(+), 19 deletions(-)
drivers/mtd/nand/gpmi-nand/bch-regs.h +7 -7
@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright 2008-2011 Freescale Semiconductor, Inc. +* Copyright 2008-2016 Freescale Semiconductor, Inc. * Copyright 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify
@@ -54,7 +54,7 @@#define MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0 11#define MX6Q_BM_BCH_FLASH0LAYOUT0_ECC0 (0x1f << MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0)#define BF_BCH_FLASH0LAYOUT0_ECC0 (v, x) \ - (GPMI_IS_MX6(x) \ + ((GPMI_IS_MX6(x) || GPMI_IS_MX7(x)) \ ? (((v) << MX6Q_BP_BCH_FLASH0LAYOUT0_ECC0) \ & MX6Q_BM_BCH_FLASH0LAYOUT0_ECC0) \ : (((v) << BP_BCH_FLASH0LAYOUT0_ECC0) \
@@ -65,7 +65,7 @@#define MX6Q_BM_BCH_FLASH0LAYOUT0_GF_13_14 \ (0x1 << MX6Q_BP_BCH_FLASH0LAYOUT0_GF_13_14)#define BF_BCH_FLASH0LAYOUT0_GF (v, x) \ - ((GPMI_IS_MX6(x) && ((v) == 14)) \ + (((GPMI_IS_MX6(x) || GPMI_IS_MX7(x)) && ((v) == 14)) \ ? (((1) << MX6Q_BP_BCH_FLASH0LAYOUT0_GF_13_14) \ & MX6Q_BM_BCH_FLASH0LAYOUT0_GF_13_14) \ : 0 \
@@ -77,7 +77,7 @@#define MX6Q_BM_BCH_FLASH0LAYOUT0_DATA0_SIZE \ (0x3ff << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)#define BF_BCH_FLASH0LAYOUT0_DATA0_SIZE (v, x) \ - (GPMI_IS_MX6(x) \ + ((GPMI_IS_MX6(x) || GPMI_IS_MX7(x)) \ ? (((v) >> 2) & MX6Q_BM_BCH_FLASH0LAYOUT0_DATA0_SIZE) \ : ((v) & BM_BCH_FLASH0LAYOUT0_DATA0_SIZE) \ )
@@ -96,7 +96,7 @@#define MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN 11#define MX6Q_BM_BCH_FLASH0LAYOUT1_ECCN (0x1f << MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN)#define BF_BCH_FLASH0LAYOUT1_ECCN (v, x) \ - (GPMI_IS_MX6(x) \ + ((GPMI_IS_MX6(x) || GPMI_IS_MX7(x)) \ ? (((v) << MX6Q_BP_BCH_FLASH0LAYOUT1_ECCN) \ & MX6Q_BM_BCH_FLASH0LAYOUT1_ECCN) \ : (((v) << BP_BCH_FLASH0LAYOUT1_ECCN) \
@@ -107,7 +107,7 @@#define MX6Q_BM_BCH_FLASH0LAYOUT1_GF_13_14 \ (0x1 << MX6Q_BP_BCH_FLASH0LAYOUT1_GF_13_14)#define BF_BCH_FLASH0LAYOUT1_GF (v, x) \ - ((GPMI_IS_MX6(x) && ((v) == 14)) \ + (((GPMI_IS_MX6(x) || GPMI_IS_MX7(x)) && ((v) == 14)) \ ? (((1) << MX6Q_BP_BCH_FLASH0LAYOUT1_GF_13_14) \ & MX6Q_BM_BCH_FLASH0LAYOUT1_GF_13_14) \ : 0 \
@@ -119,7 +119,7 @@#define MX6Q_BM_BCH_FLASH0LAYOUT1_DATAN_SIZE \ (0x3ff << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE)#define BF_BCH_FLASH0LAYOUT1_DATAN_SIZE (v, x) \ - (GPMI_IS_MX6(x) \ + ((GPMI_IS_MX6(x) || GPMI_IS_MX7(x)) \ ? (((v) >> 2) & MX6Q_BM_BCH_FLASH0LAYOUT1_DATAN_SIZE) \ : ((v) & BM_BCH_FLASH0LAYOUT1_DATAN_SIZE) \ )
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +6 -4
@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright (C) 2008-2011 Freescale Semiconductor, Inc. +* Copyright (C) 2008-2016 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify
@@ -971,7 +971,8 @@ int gpmi_extra_init(struct gpmi_nand_data *this)struct nand_chip *chip = &this->nand;/* Enable the asynchronous EDO feature. */ -if (GPMI_IS_MX6 (this) && chip->onfi_version) { +if ((GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this)) && + chip->onfi_version) {int mode =onfi_get_async_timing_mode (chip);/* We only support the timing mode 4 and mode 5. */
@@ -1093,12 +1094,13 @@ int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip)if (GPMI_IS_MX23 (this)) { mask =MX23_BM_GPMI_DEBUG_READY0 << chip; reg =readl (r->gpmi_regs +HW_GPMI_DEBUG ); - }else if (GPMI_IS_MX28 (this) ||GPMI_IS_MX6 (this)) { + }else if (GPMI_IS_MX28 (this) ||GPMI_IS_MX6 (this) || +GPMI_IS_MX7 (this)) {/* * In the imx6, all the ready/busy pins are bound * together. So we only need to check chip 0. */ -if (GPMI_IS_MX6 (this)) +if (GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this)) chip =0 ;/* MX28 shares the same R/B register as MX6Q. */
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +24 -6
@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright (C) 2010-2015 Freescale Semiconductor, Inc. +* Copyright (C) 2010-2016 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify
@@ -110,6 +110,12 @@ static const struct gpmi_devdata gpmi_devdata_imx6sx = { .max_chain_delay = 12, }; +static const struct gpmi_devdata gpmi_devdata_imx7d = { + .type =IS_MX7D , + .bch_max_ecc_strength =62 , + .max_chain_delay =12 , +}; +static irqreturn_t bch_irq (int irq,void *cookie) {struct gpmi_nand_data *this = cookie;
@@ -601,6 +607,10 @@ static char *extra_clks_for_mx6q[GPMI_CLK_MAX] = { "gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch", }; +static char *extra_clks_for_mx7d[GPMI_CLK_MAX ] = { +"gpmi_bch_apb" , +}; +static int gpmi_get_clks (struct gpmi_nand_data *this) {struct resources *r = &this->resources;
@@ -618,6 +628,8 @@ static int gpmi_get_clks(struct gpmi_nand_data *this)/* Get extra clocks */ if (GPMI_IS_MX6 (this)) extra_clks = extra_clks_for_mx6q; +if (GPMI_IS_MX7 (this)) + extra_clks = extra_clks_for_mx7d;if (!extra_clks)return 0 ;
@@ -634,7 +646,7 @@ static int gpmi_get_clks(struct gpmi_nand_data *this) r->clock[i] = clk; } -if (GPMI_IS_MX6 (this)) +if (GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this))/* * Set the default value for the gpmi clock. *
@@ -1965,8 +1977,8 @@ static int gpmi_init_last(struct gpmi_nand_data *this)* (1) the chip is imx6, and * (2) the size of the ECC parity is byte aligned. */ -if (GPMI_IS_MX6 (this) && - ((bch_geo->gf_len * bch_geo->ecc_strength) %8 ) ==0 ) { +if ((GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this)) && + ((bch_geo->gf_len * bch_geo->ecc_strength) %8 ) ==0 ) { ecc->read_subpage = gpmi_ecc_read_subpage; chip->options |=NAND_SUBPAGE_READ ; }
@@ -1987,6 +1999,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)struct nand_chip *chip = &this->nand;struct mtd_info *mtd =nand_to_mtd (chip);int ret; +int max_chips;/* init current chip */ this->current_chip =-1 ;
@@ -2021,7 +2034,8 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)if (ret) goto err_out; - ret =nand_scan_ident (mtd,GPMI_IS_MX6 (this) ?2 :1 ,NULL ); + max_chips = (GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this)) ?2 :1 ; + ret =nand_scan_ident (mtd, max_chips,NULL );if (ret) goto err_out;
@@ -2074,7 +2088,11 @@ static const struct of_device_id gpmi_nand_id_table[] = { }, { .compatible = "fsl,imx6sx-gpmi-nand", .data = &gpmi_devdata_imx6sx, - }, {} + }, { + .compatible = "fsl,imx7d-gpmi-nand", + .data = &gpmi_devdata_imx7d, + }, { /* sentinel */ } + };MODULE_DEVICE_TABLE (of, gpmi_nand_id_table);
drivers/mtd/nand/gpmi-nand/gpmi-nand.h +5 -2
@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright (C) 2010-2011 Freescale Semiconductor, Inc. +* Copyright (C) 2010-2016 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify
@@ -123,7 +123,8 @@ enum gpmi_type {IS_MX23 ,IS_MX28 ,IS_MX6Q , -IS_MX6SX +IS_MX6SX , + IS_MX7D, }; struct gpmi_devdata {
@@ -305,6 +306,8 @@ void gpmi_copy_bits(u8 *dst, size_t dst_bit_off,#define GPMI_IS_MX28 (x) ((x)->devdata->type == IS_MX28)#define GPMI_IS_MX6Q (x) ((x)->devdata->type == IS_MX6Q)#define GPMI_IS_MX6SX (x) ((x)->devdata->type == IS_MX6SX) +#define GPMI_IS_MX7D (x) ((x)->devdata->type == IS_MX7D)#define GPMI_IS_MX6 (x) (GPMI_IS_MX6Q(x) || GPMI_IS_MX6SX(x)) +#define GPMI_IS_MX7 (x) (GPMI_IS_MX7D(x))#endif
Signature · 1 line
1.9.1
Rob Herring
maintainerRe: [PATCH v3 2/6] Documentation: dt: mtd: gpmi: document the clocks and clock-names in DT property
In reply to Han XuQuoted 15 lines · Han Xu
add the clocks and clock-names in DT property, gpmi-io clock is mandatory for all platforms, but some platforms, such as i.MX6Q may need more extra clocks for submodules. More details please refer to the SoC reference manual.
Signed-off-by Han Xu <[email protected]>--- Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/mtd/gpmi-nand.txt +0
-0
Documentation/devicetree/bindings/mtd/gpmi-nand.txt Required properties: · line 22
Quoted 10 lines
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +7
-0@@ -13,6 +13,13 @@ Required properties: and GPMI DMA channel ID. Refer to dma.txt and fsl-mxs-dma.txt for details. - dma-names: Must be "rx-tx". + - clocks : The clocks needed by the gpmi controller. This field varies + depends on the SoC design, "gpmi-io" is mandatory but some platforms may + need several extra clocks, such as i.MX6 series, which requires "gpmi_apb, + gpmi_bch, gpmi_bch_apb and per1_bch" for all submodules, while i.MX7 only + need gpmi_bch_apb. Please refer to the HW design manual. + - clock-names : the name of the clocks, please refer to the HW design + manual.
No please list the names here (I assume what is above?). Also need to specify the order of the clocks. It would be clearest if you list things by exact compatible strings.
Rob
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 6/6] Documentation: dt: mtd: gpmi: document the new supported chip in DT
In reply to Han XuQuoted 6 lines · Han Xu
listed all supported chips in DT.
Signed-off-by Han Xu <[email protected]>--- Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Re: [PATCH v3 2/6] Documentation: dt: mtd: gpmi: document the clocks and clock-names in DT property
In reply to Rob HerringQuoted 22 lines · Rob Herring
Quoted 21 lines · Han Xu
add the clocks and clock-names in DT property, gpmi-io clock is mandatory for all platforms, but some platforms, such as i.MX6Q may need more extra clocks for submodules. More details please refer to the SoC reference manual.
Signed-off-by Han Xu <[email protected]>--- Documentation/devicetree/bindings/mtd/gpmi-nand.txt | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/mtd/gpmi-nand.txt +3
-0@@ -13,6 +13,13 @@ Required properties: and GPMI DMA channel ID. Refer to dma.txt and fsl-mxs-dma.txt for details. - dma-names: Must be "rx-tx". + - clocks : The clocks needed by the gpmi controller. This field varies + depends on the SoC design, "gpmi-io" is mandatory but some platforms may + need several extra clocks, such as i.MX6 series, which requires "gpmi_apb,
Quoted 8 lines
Documentation/devicetree/bindings/mtd/gpmi-nand.txt Required properties: · line 22
Quoted 4 lines
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +4
-0+ gpmi_bch, gpmi_bch_apb and per1_bch" for all submodules, while i.MX7 only + need gpmi_bch_apb. Please refer to the HW design manual. + - clock-names : the name of the clocks, please refer to the HW design + manual.No please list the names here (I assume what is above?). Also need to specify the order of the clocks. It would be clearest if you list things by exact compatible strings.
These are the exact clocks needed by i.MX6 and i.MX7. Order doesn't matter.
Quoted 6 lines
Rob
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Signature · 7 lines
Sincerely, Han XU -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 4/6] mtd: nand: gpmi: correct bitflip for erased NAND page
In reply to Han XuQuoted 104 lines · On Fri, 24 Jun 2016 16:40:09 -0500 Han Xu…
i.MX6QP and i.MX7D BCH module integrated a new feature to detect the bitflip number for erased NAND page. So for these two platform, set the erase threshold to
ecc_strengthand if bitflip detected, GPMI driver will correct the data to all0xFF.Signed-off-by Han Xu <[email protected]>--- drivers/mtd/nand/gpmi-nand/bch-regs.h | 10 +++++++++ drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 5 +++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 37 +++++++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-)drivers/mtd/nand/gpmi-nand/bch-regs.h +10
-0@@ -30,7 +30,13 @@#define BM_BCH_CTRL_COMPLETE_IRQ (1 << 0)#define HW_BCH_STATUS0 0x00000010 +#define HW_BCH_MODE 0x00000020 +#define BP_BCH_MODE_ERASE_THRESHOLD 0 +#define BM_BCH_MODE_ERASE_THRESHOLD (0xff << BP_BCH_MODE_ERASE_THRESHOLD) +#define BF_BCH_MODE_ERASE_THRESHOLD (v) \ + (((v) << BP_BCH_MODE_ERASE_THRESHOLD) & BM_BCH_MODE_ERASE_THRESHOLD) +#define HW_BCH_ENCODEPTR 0x00000030#define HW_BCH_DATAPTR 0x00000040#define HW_BCH_METAPTR 0x00000050@@ -125,4 +131,8 @@ )#define HW_BCH_VERSION 0x00000160 +#define HW_BCH_DEBUG1 0x00000170 +#define BP_BCH_DEBUG1_ERASED_ZERO_COUNT 0 +#define BM_BCH_DEBUG1_ERASED_ZERO_COUNT \ + (0x1ff << BP_BCH_DEBUG1_ERASED_ZERO_COUNT)#endif drivers/mtd/nand/gpmi-nand/gpmi-lib.c +5
-0@@ -298,6 +298,11 @@ int bch_set_geometry(struct gpmi_nand_data *this) | BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this), r->bch_regs + HW_BCH_FLASH0LAYOUT1); +/* Set erase threshold to ecc_strength for mx6qp and mx7 */ +if (GPMI_IS_MX6QP (this) ||GPMI_IS_MX7 (this)) +writel (BF_BCH_MODE_ERASE_THRESHOLD (ecc_strength), + r->bch_regs +HW_BCH_MODE ); +/* Set *all* chip selects to use layout 0. */ writel (0 , r->bch_regs +HW_BCH_LAYOUTSELECT );drivers/mtd/nand/gpmi-nand/gpmi-nand.c +15
-3@@ -1043,11 +1043,12 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, {struct gpmi_nand_data *this =nand_get_controller_data (chip);struct bch_geometry *nfc_geo = &this->bch_geometry; +void __iomem *bch_regs = this->resources.bch_regs;void *payload_virt;dma_addr_t payload_phys;void *auxiliary_virt;dma_addr_t auxiliary_phys; -unsigned int i; +unsigned int i, j;unsigned char *status;unsigned int max_bitflips =0 ;int ret;@@ -1087,9 +1088,14 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, nfc_geo->payload_size, payload_virt, payload_phys); -for (i =0 ; i < nfc_geo->ecc_chunk_count; i++, status++) { -if ((*status ==STATUS_GOOD ) || (*status ==STATUS_ERASED )) +for (i =0 , j =0 ; i < nfc_geo->ecc_chunk_count; i++, status++) { +if (*status ==STATUS_GOOD ) +continue ; +if (*status ==STATUS_ERASED ) { +/* count the number of erased chunks */ + j++;continue ; + }if (*status ==STATUS_UNCORRECTABLE ) {int eccbits = nfc_geo->ecc_strength * nfc_geo->gf_len;@@ -1098,6 +1104,12 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,int eccbytes;int flips; +/* shortcut for i.MX7 and i.MX6QP */ +if (GPMI_IS_MX6QP (this) ||GPMI_IS_MX7 (this)) { + mtd->ecc_stats.failed++; +continue ; + } +/* Read ECC bytes into our internal raw_buffer */ offset = nfc_geo->metadata_size *8 ; offset += ((8 * nfc_geo->ecc_chunk_size) + eccbits) * (i +1 );
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, · line 1185
Quoted 7 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +4
-0@@ -1167,6 +1179,25 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, max_bitflips = max_t(unsigned int, max_bitflips, *status); } +/* +* i.MX6QP and i.MX7 have dedicate register to check bitflips in the +* page, while it cannot tell in which chunk bitflips locate, memset +* all the data if bitflips exist and all chunks are erased.
Hm, that's a big problem: how can we decide if the number of bitflips per ECC chunk exceed the bitflips threshold?
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, · line 1194
Quoted 9 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +9
-0+*/ +if (j == nfc_geo->ecc_chunk_count && + (GPMI_IS_MX6QP (this) ||GPMI_IS_MX7 (this))) { +int flips; + + flips =readl (bch_regs +HW_BCH_DEBUG1 ); +if (flips) { + max_bitflips = max_t(unsigned int, max_bitflips, + flips);
max_bitflips is supposed to contain the maximum number of bitflips per ECC chunk not per page, so nand_base might return -EUCLEAN while it should have returned zero in some cases.
Given this new information I'm not sure the HW solution to count bitflips in erased pages is appropriate.
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, · line 1203
Quoted 9 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +6
-0+memset (buf, ~0 , nfc_geo->payload_size); +memset (chip->oob_poi, ~0 , mtd->oobsize); + mtd->ecc_stats.corrected += flips; + } + } +if (oob_required) {/* * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob()
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html