mtd: nand: gpmi: gpmi-nand DSM and bitflip support
v3 cover mtd: nand: gpmi: gpmi-nand DSM and bitflip support
v1 ---> v2
change the erased page bitflip threshold to ecc strength in bitflip patch
v2 ---> v3
remove unnecessary function in mxs-dma
change the log message when legacy_set_geometry failed fix the comment message for bitflip
add comma for all field entries
Han Xu (4):
mtd: nand: gpmi: may use minimum required ecc for 744 oobsize NAND
mtd: nand: gpmi: add GPMI NAND support for i.MX7D
mtd: nand: gpmi: correct bitflip for erased NAND page
mtd: nand: gpmi: support NAND on i.MX6UL
Huang Shijie (2):
mtd: nand: gpmi: add gpmi dsm supend/resume support
dmaengine: mxs: support i.MX7D and deep sleep mode
drivers/dma/mxs-dma.c | 64 +++++++++++++++-- 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 | 128 ++++++++++++++++++++++++++++----- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 14 +++- 5 files changed, 207 insertions(+), 38 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 6/6 mtd: nand: gpmi: support NAND on i.MX6UL
support GPMI NAND on i.MX6UL
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 9 +++++++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +9 -0
@@ -89,6 +89,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;
@@ -2016,6 +2022,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 = (void *)&gpmi_devdata_imx6ul, + }, { .compatible = "fsl,imx7d-gpmi-nand", .data = (void *)&gpmi_devdata_imx7d, }
drivers/mtd/nand/gpmi-nand/gpmi-nand.h +3 -1
@@ -126,6 +126,7 @@ enum gpmi_type {IS_MX6QP ,IS_MX6SX ,IS_MX7D , + IS_MX6UL, }; struct gpmi_devdata {
@@ -310,8 +311,9 @@ 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 1/6 mtd: nand: gpmi: add gpmi dsm supend/resume support
In reply to Han XuFrom: Huang Shijie <[email protected]>
i.MX6SX supports deep sleep mode(DSM) that may turn off GPMI/BCH power during suspend, add gpmi nand suspend/resume function to release DMA channel in suspend function and re-init GPMI/BCH controller during resume function.
Although it is not necessary to restore GPMI/BCH registers value for i.MX6QDL, the code doesn't distinguish different platforms to keep the code simple.
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +44 -1
@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright (C) 2010-2011 Freescale Semiconductor, Inc. +* Copyright (C) 2010-2015 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify
@@ -2036,9 +2036,52 @@ static int gpmi_nand_remove(struct platform_device *pdev)return 0 ; } +static int gpmi_pm_suspend (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); + +release_dma_channels (this); +return 0 ; +} + +static int gpmi_pm_resume (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); +int ret; + + ret =acquire_dma_channels (this); +if (ret <0 ) +return ret; + +/* re-init the GPMI registers */ + this->flags &= ~GPMI_TIMING_INIT_OK ; + ret =gpmi_init (this); +if (ret) { +dev_err (this->dev,"Error setting GPMI : %d\n" , ret); +return ret; + } + +/* re-init the BCH registers */ + ret =bch_set_geometry (this); +if (ret) { +dev_err (this->dev,"Error setting BCH : %d\n" , ret); +return ret; + } + +/* re-init others */ +gpmi_extra_init (this); + +return 0 ; +} + +static const struct dev_pm_ops gpmi_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (gpmi_pm_suspend, gpmi_pm_resume) +}; +static struct platform_driver gpmi_nand_driver = { .driver = { .name ="gpmi-nand" , + .pm = &gpmi_pm_ops, .of_match_table = gpmi_nand_id_table, }, .probe = gpmi_nand_probe,
Signature · 1 line
1.9.1
PATCH v3 3/6 mtd: nand: gpmi: may use minimum required ecc for 744 oobsize NAND
In reply to Han XuBy default NAND driver will choose the highest ecc strength that oob could contain, in this case, for some 8K+744 NAND flash, the ecc strength will be up to 52bit, which beyonds the i.MX6QDL BCH capability (40bit).
This patch allows the NAND driver try to use minimum required ecc strength if it failed to use the highest ecc, even without explicitly claiming "fsl,use-minimum-ecc" in dts.
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +14 -12
@@ -136,7 +136,7 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)* * We may have available oob space in this case. */ -static bool set_geometry_by_ecc_info (struct gpmi_nand_data *this) +static int set_geometry_by_ecc_info (struct gpmi_nand_data *this) {struct bch_geometry *geo = &this->bch_geometry;struct mtd_info *mtd = &this->mtd;
@@ -145,7 +145,7 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this)unsigned int block_mark_bit_offset;if (!(chip->ecc_strength_ds >0 && chip->ecc_step_ds >0 )) -return false; +return -EINVAL ;switch (chip->ecc_step_ds) {case SZ_512 :
@@ -158,19 +158,19 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this)dev_err (this->dev,"unsupported nand chip. ecc bits : %d, ecc size : %d\n" , chip->ecc_strength_ds, chip->ecc_step_ds); -return false; +return -EINVAL ; } geo->ecc_chunk_size = chip->ecc_step_ds; geo->ecc_strength =round_up (chip->ecc_strength_ds,2 );if (!gpmi_check_ecc (this)) -return false; +return -EINVAL ;/* Keep the C >= O */ if (geo->ecc_chunk_size < mtd->oobsize) {dev_err (this->dev,"unsupported nand chip. ecc size: %d, oob size : %d\n" , chip->ecc_step_ds, mtd->oobsize); -return false; +return -EINVAL ; }/* The default value, see comment in the legacy_set_geometry(). */
@@ -242,7 +242,7 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this) +ALIGN (geo->ecc_chunk_count,4 );if (!this->swap_block_mark) -return true; +return 0 ;/* For bit swap. */ block_mark_bit_offset = mtd->writesize * 8 -
@@ -251,7 +251,7 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this) geo->block_mark_byte_offset = block_mark_bit_offset /8 ; geo->block_mark_bit_offset = block_mark_bit_offset %8 ; -return true; +return 0 ; }static int legacy_set_geometry (struct gpmi_nand_data *this)
@@ -285,7 +285,8 @@ static int legacy_set_geometry(struct gpmi_nand_data *this) geo->ecc_strength =get_ecc_strength (this);if (!gpmi_check_ecc (this)) {dev_err (this->dev, -"required ecc strength of the NAND chip: %d is not supported by the GPMI controller (%d)\n" , +"ecc strength: %d cannot be supported by the controller (%d)\n" +"try to use minimum ecc strength that NAND chip required\n" , geo->ecc_strength, this->devdata->bch_max_ecc_strength);return -EINVAL ;
@@ -366,10 +367,11 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)int common_nfc_set_geometry (struct gpmi_nand_data *this) { -if (of_property_read_bool (this->dev->of_node,"fsl,use-minimum-ecc" ) - &&set_geometry_by_ecc_info (this)) -return 0 ; -return legacy_set_geometry (this); +if ((of_property_read_bool (this->dev->of_node,"fsl,use-minimum-ecc" )) + ||legacy_set_geometry (this)) +return set_geometry_by_ecc_info (this); + +return 0 ; }struct dma_chan *get_dma_chan (struct gpmi_nand_data *this)
Signature · 1 line
1.9.1
PATCH v3 5/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 | 24 +++++++++++++++++++++++- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 5 ++++- 4 files changed, 42 insertions(+), 2 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 +23 -1
@@ -71,6 +71,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 ,
@@ -1010,6 +1016,7 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, {struct gpmi_nand_data *this = chip->priv;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;
@@ -1018,6 +1025,7 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,unsigned char *status;unsigned int max_bitflips =0 ;int ret; +int flag =0 ;dev_dbg (this->dev,"page number is : %d\n" , page); ret = read_page_prepare(this, buf, nfc_geo->payload_size,
@@ -1050,9 +1058,16 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, status = auxiliary_virt + nfc_geo->auxiliary_status_offset;for (i =0 ; i < nfc_geo->ecc_chunk_count; i++, status++) { -if ((*status ==STATUS_GOOD ) || (*status ==STATUS_ERASED )) +if (*status ==STATUS_GOOD )continue ; +if (*status ==STATUS_ERASED ) { +if (GPMI_IS_MX6QP (this) ||GPMI_IS_MX7 (this)) +if (readl (bch_regs +HW_BCH_DEBUG1 )) + flag =1 ; +continue ; + } +if (*status ==STATUS_UNCORRECTABLE ) { mtd->ecc_stats.failed++;continue ;
@@ -1081,6 +1096,10 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, nfc_geo->payload_size, payload_virt, payload_phys); +/* if bitflip occurred in erased page, change data to all 0xff */ +if (flag) +memset (buf,0xff , nfc_geo->payload_size); +return max_bitflips; }
@@ -1991,6 +2010,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 = (void *)&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, };
@@ -306,9 +307,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: 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 | 24 ++++++++++++++++++++---- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 7 +++++-- 4 files changed, 38 insertions(+), 17 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-2015 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-2015 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 +20 -4
@@ -77,6 +77,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;
@@ -575,6 +581,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;
@@ -592,6 +602,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 ;
@@ -608,7 +620,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. *
@@ -1869,7 +1881,7 @@ 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) && +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 ;
@@ -1936,7 +1948,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 ); + ret =nand_scan_ident (mtd,GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this)\ + ?2 :1 ,NULL );if (ret) goto err_out;
@@ -1980,7 +1993,10 @@ 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 = (void *)&gpmi_devdata_imx7d, + } };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-2015 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 {
@@ -306,6 +307,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
PATCH v3 2/6 dmaengine: mxs: support i.MX7D and deep sleep mode
In reply to Han XuFrom: Huang Shijie <[email protected]>
The patch support i.MX7D platform by adding extra DMA clock.
Deep Sleep Mode(dsm) turns off the power for APBH DMA module, add suspend/resume function and re-init the APBH DMA during resume.
--- drivers/dma/mxs-dma.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 6 deletions(-)
drivers/dma/mxs-dma.c +58 -6
@@ -1,5 +1,5 @@/* -* Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved. * * Refer to drivers/dma/imx-sdma.c *
@@ -28,7 +28,6 @@#include <linux/of_device.h> #include <linux/of_dma.h> #include <linux/list.h> -#include <asm/irq.h> #include "dmaengine.h"
@@ -135,6 +134,7 @@ enum mxs_dma_devtype {enum mxs_dma_id {IMX23_DMA ,IMX28_DMA , +IMX7D_DMA , };struct mxs_dma_engine {
@@ -142,6 +142,7 @@ struct mxs_dma_engine {enum mxs_dma_devtype type;void __iomem *base;struct clk *clk; +struct clk *clk_io;struct dma_device dma_device;struct device_dma_parameters dma_parms;struct mxs_dma_chan mxs_chans[MXS_DMA_CHANNELS ];
@@ -167,6 +168,9 @@ static struct mxs_dma_type mxs_dma_types[] = { }, { .id = IMX28_DMA, .type = MXS_DMA_APBX, + }, { + .id = IMX7D_DMA, + .type = MXS_DMA_APBH, } };
@@ -184,6 +188,9 @@ static const struct platform_device_id mxs_dma_ids[] = { .name = "imx28-dma-apbx", .driver_data = (kernel_ulong_t) &mxs_dma_types[3], }, { + .name = "imx7d-dma-apbh", + .driver_data = (kernel_ulong_t) &mxs_dma_types[4], + }, {/* end of list */ } };
@@ -193,6 +200,7 @@ static const struct of_device_id mxs_dma_dt_ids[] = { { .compatible = "fsl,imx23-dma-apbx", .data = &mxs_dma_ids[1], }, { .compatible = "fsl,imx28-dma-apbh", .data = &mxs_dma_ids[2], }, { .compatible = "fsl,imx28-dma-apbx", .data = &mxs_dma_ids[3], }, + { .compatible = "fsl,imx7d-dma-apbh", .data = &mxs_dma_ids[4], }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mxs_dma_dt_ids);
@@ -440,6 +448,12 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)if (ret) goto err_clk; +if (mxs_dma->dev_id ==IMX7D_DMA ) { + ret =clk_prepare_enable (mxs_dma->clk_io); +if (ret) + goto err_clk_unprepare; + } +mxs_dma_reset_chan (chan);dma_async_tx_descriptor_init (&mxs_chan->desc, chan);
@@ -450,6 +464,8 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)return 0 ; +err_clk_unprepare: +clk_disable_unprepare (mxs_dma->clk); err_clk:free_irq (mxs_chan->chan_irq, mxs_dma); err_irq:
@@ -471,6 +487,9 @@ static void mxs_dma_free_chan_resources(struct dma_chan *chan)dma_free_coherent (mxs_dma->dma_device.dev,CCW_BLOCK_SIZE , mxs_chan->ccw, mxs_chan->ccw_phys); +if (mxs_dma->dev_id ==IMX7D_DMA ) +clk_disable_unprepare (mxs_dma->clk_io); +clk_disable_unprepare (mxs_dma->clk); }
@@ -693,7 +712,7 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan,return mxs_chan->status; } -static int __init mxs_dma_init (struct mxs_dma_engine *mxs_dma) +static int mxs_dma_init (struct mxs_dma_engine *mxs_dma) {int ret;
@@ -701,6 +720,12 @@ static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)if (ret)return ret; +if (mxs_dma->dev_id ==IMX7D_DMA ) { + ret =clk_prepare_enable (mxs_dma->clk_io); +if (ret) + goto err_out; + } + ret =stmp_reset_block (mxs_dma->base);if (ret) goto err_out;
@@ -803,9 +828,19 @@ static int __init mxs_dma_probe(struct platform_device *pdev)if (IS_ERR (mxs_dma->base))return PTR_ERR (mxs_dma->base); - mxs_dma->clk =devm_clk_get (&pdev->dev,NULL ); -if (IS_ERR (mxs_dma->clk)) -return PTR_ERR (mxs_dma->clk); +if (mxs_dma->dev_id ==IMX7D_DMA ) { + mxs_dma->clk =devm_clk_get (&pdev->dev,"dma_apbh_bch" ); +if (IS_ERR (mxs_dma->clk)) +return PTR_ERR (mxs_dma->clk); + mxs_dma->clk_io =devm_clk_get (&pdev->dev,"dma_apbh_io" ); +if (IS_ERR (mxs_dma->clk_io)) +return PTR_ERR (mxs_dma->clk_io); + + }else { + mxs_dma->clk =devm_clk_get (&pdev->dev,NULL ); +if (IS_ERR (mxs_dma->clk)) +return PTR_ERR (mxs_dma->clk); + }dma_cap_set (DMA_SLAVE , mxs_dma->dma_device.cap_mask);dma_cap_set (DMA_CYCLIC , mxs_dma->dma_device.cap_mask);
@@ -835,6 +870,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev) mxs_dma->pdev = pdev; mxs_dma->dma_device.dev = &pdev->dev; +dev_set_drvdata (&pdev->dev, mxs_dma);/* mxs_dma gets 65535 bytes maximum sg size */ mxs_dma->dma_device.dev->dma_parms = &mxs_dma->dma_parms;
@@ -872,9 +908,25 @@ static int __init mxs_dma_probe(struct platform_device *pdev)return 0 ; } +static int mxs_dma_pm_resume (struct device *dev) +{ +struct mxs_dma_engine *mxs_dma =dev_get_drvdata (dev); +int ret; + + ret =mxs_dma_init (mxs_dma); +if (ret) +return ret; +return 0 ; +} + +static const struct dev_pm_ops mxs_dma_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (NULL , mxs_dma_pm_resume) +}; +static struct platform_driver mxs_dma_driver = { .driver = { .name ="mxs-dma" , + .pm = &mxs_dma_pm_ops, .of_match_table = mxs_dma_dt_ids, }, .id_table = mxs_dma_ids,
Signature · 1 line
1.9.1
Re: [PATCH v3 1/6] mtd: nand: gpmi: add gpmi dsm supend/resume support
In reply to Han XuQuoted 7 lines · Han Xu
From: Huang Shijie <[email protected]>
i.MX6SX supports deep sleep mode(DSM) that may turn off GPMI/BCH power during suspend, add gpmi nand suspend/resume function to release DMA channel in suspend function and re-init GPMI/BCH controller during resume function.
Just a question regarding gpmi_pm_resume() errror reporting
Is there a reason that the retrun value of gpmi_extra_init() is not checked ? gpmi_extra_init() can retrun -ENOMEM or -EINVAL via return enable_edo_mode(), while the -EINVAL would produce a dev_err message, -ENOMEM does not so maybe this also wants to include a if(ret) {...} ? - something like the below
Quoted 51 lines
Although it is not necessary to restore GPMI/BCH registers value for i.MX6QDL, the code doesn't distinguish different platforms to keep the code simple.
Signed-off-by Huang Shijie <[email protected]>Signed-off-by Han Xu <[email protected]>--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)drivers/mtd/nand/gpmi-nand/gpmi-nand.c +25
-1@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright (C) 2010-2011 Freescale Semiconductor, Inc. +* Copyright (C) 2010-2015 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify @@ -2036,9 +2036,52 @@ static int gpmi_nand_remove(struct platform_device *pdev)return 0 ; } +static int gpmi_pm_suspend (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); + +release_dma_channels (this); +return 0 ; +} + +static int gpmi_pm_resume (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); +int ret; + + ret =acquire_dma_channels (this); +if (ret <0 ) +return ret; + +/* re-init the GPMI registers */ + this->flags &= ~GPMI_TIMING_INIT_OK ; + ret =gpmi_init (this); +if (ret) { +dev_err (this->dev,"Error setting GPMI : %d\n" , ret); +return ret; + }
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_remove(struct platform_device *pdev) · line 2072
Quoted 10 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +10
-0+ +/* re-init the BCH registers */ + ret =bch_set_geometry (this); +if (ret) { +dev_err (this->dev,"Error setting BCH : %d\n" , ret); +return ret; + } + +/* re-init others */ +gpmi_extra_init (this);
report failure of enable_edo_mode() ?
if (ret) {
dev_err(this->dev, "Error enabling EDO mode : %d\n", ret);
return ret;
}Quoted 18 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +9
-0+ +return 0 ; +} + +static const struct dev_pm_ops gpmi_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (gpmi_pm_suspend, gpmi_pm_resume) +}; +static struct platform_driver gpmi_nand_driver = { .driver = { .name ="gpmi-nand" , + .pm = &gpmi_pm_ops, .of_match_table = gpmi_nand_id_table, }, .probe = gpmi_nand_probe,Signature · 1 line
1.9.1
Re: [PATCH v3 4/6] mtd: nand: gpmi: add GPMI NAND support for i.MX7D
In reply to Han XuQuoted 2 lines · Han Xu
support GPMI NAND on i.MX7D
minor coding style fixup suggestion ingpmi_extra_init()gpmi_nand_init()gpmi_init_last()
see below.
Quoted 89 lines
Signed-off-by Han Xu <[email protected]>--- 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 | 24 ++++++++++++++++++++---- drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 7 +++++-- 4 files changed, 38 insertions(+), 17 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-2015 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 +1
-1@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright (C) 2008-2011 Freescale Semiconductor, Inc. +* Copyright (C) 2008-2015 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify
drivers/mtd/nand/gpmi-nand/gpmi-lib.c int gpmi_extra_init(struct gpmi_nand_data *this) · line 975
Quoted 6 lines
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +2
-1@@ -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) {
This probably should be:
if ((GPMI_IS_MX6(this) || GPMI_IS_MX7(this)) &&
chip->onfi_version) {Quoted 66 lines
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +3
-2int 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 +13
-1@@ -77,6 +77,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;@@ -575,6 +581,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;@@ -592,6 +602,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 ;@@ -608,7 +620,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. *
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_init_last(struct gpmi_nand_data *this) · line 1885
Quoted 6 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1
-1@@ -1869,7 +1881,7 @@ 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) && +if ((GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this)) && ((bch_geo->gf_len * bch_geo->ecc_strength) %8 ) ==0 ) {
looks like that indentation needs fixing
if ((GPMI_IS_MX6(this) || GPMI_IS_MX7(this)) &&
((bch_geo->gf_len * bch_geo->ecc_strength) % 8) == 0) {
or
if ((GPMI_IS_MX6(this) || GPMI_IS_MX7(this)) && ((bch_geo->gf_len * bch_geo->ecc_strength) % 8) == 0) {
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_init(struct gpmi_nand_data *this) · line 1952
Quoted 9 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +2
-1ecc->read_subpage = gpmi_ecc_read_subpage; chip->options |=NAND_SUBPAGE_READ ;@@ -1936,7 +1948,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 ); + ret =nand_scan_ident (mtd,GPMI_IS_MX6 (this) ||GPMI_IS_MX7 (this)\ + ?2 :1 ,NULL );
I think this should preferably be:
ret = nand_scan_ident(mtd, GPMI_IS_MX6(this) || GPMI_IS_MX7(this) ? 2 : 1, NULL);
Quoted 50 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +4
-1if (ret) goto err_out;@@ -1980,7 +1993,10 @@ 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 = (void *)&gpmi_devdata_imx7d, + } };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-2015 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 {@@ -306,6 +307,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
Re: [PATCH v3 1/6] mtd: nand: gpmi: add gpmi dsm supend/resume support
In reply to Nicholas Mc GuireQuoted 80 lines · Nicholas Mc Guire
Quoted 7 lines · Han Xu
From: Huang Shijie <[email protected]>
i.MX6SX supports deep sleep mode(DSM) that may turn off GPMI/BCH power during suspend, add gpmi nand suspend/resume function to release DMA channel in suspend function and re-init GPMI/BCH controller during resume function.
Just a question regarding
gpmi_pm_resume()errror reporting
Is there a reason that the retrun value ofgpmi_extra_init()is not checked ?gpmi_extra_init()can retrun-ENOMEMor-EINVALvia returnenable_edo_mode(), while the-EINVALwould produce adev_errmessage,-ENOMEMdoes not so maybe this also wants to include a if(ret) {...} ? - something like the belowQuoted 51 lines
Although it is not necessary to restore GPMI/BCH registers value for i.MX6QDL, the code doesn't distinguish different platforms to keep the code simple.
Signed-off-by Huang Shijie <[email protected]>Signed-off-by Han Xu <[email protected]>--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)drivers/mtd/nand/gpmi-nand/gpmi-nand.c +25
-1@@ -1,7 +1,7 @@/* * Freescale GPMI NAND Flash Driver * -* Copyright (C) 2010-2011 Freescale Semiconductor, Inc. +* Copyright (C) 2010-2015 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify @@ -2036,9 +2036,52 @@ static int gpmi_nand_remove(struct platform_device *pdev)return 0 ; } +static int gpmi_pm_suspend (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); + +release_dma_channels (this); +return 0 ; +} + +static int gpmi_pm_resume (struct device *dev) +{ +struct gpmi_nand_data *this =dev_get_drvdata (dev); +int ret; + + ret =acquire_dma_channels (this); +if (ret <0 ) +return ret; + +/* re-init the GPMI registers */ + this->flags &= ~GPMI_TIMING_INIT_OK ; + ret =gpmi_init (this); +if (ret) { +dev_err (this->dev,"Error setting GPMI : %d\n" , ret); +return ret; + }drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_remove(struct platform_device *pdev) · line 2072
Quoted 10 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +10
-0+ +/* re-init the BCH registers */ + ret =bch_set_geometry (this); +if (ret) { +dev_err (this->dev,"Error setting BCH : %d\n" , ret); +return ret; + } + +/* re-init others */ +gpmi_extra_init (this);report failure of
enable_edo_mode()?
Quoted 4 lines
if (ret) {
dev_err(this->dev, "Error enabling EDO mode : %d\n", ret);
return ret;
}I think it's better that we do not report the failure of the enable_edo_mode() here. If we do so, the gpmi may cannot work when the enable_edo_mode() fails.
But if we do not report it, the gpmi still can work.
thanks
Huang Shijie
Re: [PATCH v3 2/6] dmaengine: mxs: support i.MX7D and deep sleep mode
In reply to Han Xudrivers/dma/mxs-dma.c line 31
Quoted 5 lines · Han Xu
drivers/dma/mxs-dma.c +0
-1@@ -28,7 +28,6 @@#include <linux/of_device.h> #include <linux/of_dma.h> #include <linux/list.h> -
Pl dont change at random places
Quoted 10 lines
drivers/dma/mxs-dma.c +6
-0+if (mxs_dma->dev_id ==IMX7D_DMA ) { + ret =clk_prepare_enable (mxs_dma->clk_io); +if (ret) + goto err_clk_unprepare; + } +mxs_dma_reset_chan (chan);dma_async_tx_descriptor_init (&mxs_chan->desc, chan);
drivers/dma/mxs-dma.c static int mxs_dma_alloc_chan_resources(struct dma_chan *chan) · line 468
Quoted 5 lines
drivers/dma/mxs-dma.c +2
-0@@ -450,6 +464,8 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)return 0 ; +err_clk_unprepare: +clk_disable_unprepare (mxs_dma->clk);
and this doesn't look right. You are calling this for failure on clk_prepare_enable() so if clock prepare failed you are still going to disable and unprepare??
drivers/dma/mxs-dma.c static enum dma_status mxs_dma_tx_status(struct dma_chan *chan, · line 715
Quoted 2 lines
drivers/dma/mxs-dma.c +1
-1-static int __init mxs_dma_init (struct mxs_dma_engine *mxs_dma) +static int mxs_dma_init (struct mxs_dma_engine *mxs_dma)
this should be separate change explaining why
drivers/dma/mxs-dma.c static int __init mxs_dma_probe(struct platform_device *pdev) · line 919
Quoted 9 lines
drivers/dma/mxs-dma.c +9
-0+static int mxs_dma_pm_resume (struct device *dev) +{ +struct mxs_dma_engine *mxs_dma =dev_get_drvdata (dev); +int ret; + + ret =mxs_dma_init (mxs_dma); +if (ret) +return ret; +return 0 ;
Aren't you supposed to prepare and unprepare clock in PM handlers too?
Signature · 1 line
~Vinod
Re: [PATCH v3 2/6] dmaengine: mxs: support i.MX7D and deep sleep mode
Quoted 8 lines · Vinod Koul
drivers/dma/mxs-dma.c line 31
Quoted 5 lines · Han Xu
drivers/dma/mxs-dma.c +0
-1@@ -28,7 +28,6 @@#include <linux/of_device.h> #include <linux/of_dma.h> #include <linux/list.h> -Pl dont change at random places
It's not a random place, i.MX7D need an extra clock clk_io for APBH DMA, I will add more
comments here
Quoted 12 lines
Quoted 12 lines
drivers/dma/mxs-dma.c +6
-0+if (mxs_dma->dev_id ==IMX7D_DMA ) { + ret =clk_prepare_enable (mxs_dma->clk_io); +if (ret) + goto err_clk_unprepare; + } +mxs_dma_reset_chan (chan);dma_async_tx_descriptor_init (&mxs_chan->desc, chan);@@ -450,6 +464,8 @@ static int mxs_dma_alloc_chan_resources(struct dma_chan *chan)
Quoted 8 lines
drivers/dma/mxs-dma.c static int mxs_dma_alloc_chan_resources(struct dma_chan *chan) · line 468
Quoted 4 lines
drivers/dma/mxs-dma.c +2
-0return 0 ; +err_clk_unprepare: +clk_disable_unprepare (mxs_dma->clk);and this doesn't look right. You are calling this for failure on
clk_prepare_enable()so if clock prepare failed you are still going to disable and unprepare??
This is also for i.MX7D, if enable mxs_dma->clk_io failed, disable mxs_dma->clk as well.
Quoted 5 lines
drivers/dma/mxs-dma.c static enum dma_status mxs_dma_tx_status(struct dma_chan *chan, · line 715
Quoted 3 lines
drivers/dma/mxs-dma.c +1
-1-static int __init mxs_dma_init (struct mxs_dma_engine *mxs_dma) +static int mxs_dma_init (struct mxs_dma_engine *mxs_dma)this should be separate change explaining why
I will separate the clock change and PM change to two patches.
Quoted 12 lines
drivers/dma/mxs-dma.c static int __init mxs_dma_probe(struct platform_device *pdev) · line 919
Quoted 10 lines
drivers/dma/mxs-dma.c +9
-0+static int mxs_dma_pm_resume (struct device *dev) +{ +struct mxs_dma_engine *mxs_dma =dev_get_drvdata (dev); +int ret; + + ret =mxs_dma_init (mxs_dma); +if (ret) +return ret; +return 0 ;Aren't you supposed to prepare and unprepare clock in PM handlers too?
APBH DMA was dedicate for GPMI NAND driver, NAND driver will release all DMA resources
when suspend and acquire DMA resources when resume. All clock enable/disable were handled
in these functions. Please refer to the patch serial [PATCH v3 1/6]
mtd: nand: gpmi: add gpmi
dsm supend/resume support
Quoted 7 lines
--
~Vinod______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/