|
@@ -16,7 +16,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
|
|
|
|
--- a/drivers/mtd/nand/raw/qcom_nandc.c
|
|
--- a/drivers/mtd/nand/raw/qcom_nandc.c
|
|
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
|
|
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
|
|
-@@ -159,6 +159,11 @@
|
|
|
|
|
|
+@@ -158,6 +158,11 @@
|
|
/* NAND_CTRL bits */
|
|
/* NAND_CTRL bits */
|
|
#define BAM_MODE_EN BIT(0)
|
|
#define BAM_MODE_EN BIT(0)
|
|
|
|
|
|
@@ -28,7 +28,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
/*
|
|
/*
|
|
* the NAND controller performs reads/writes with ECC in 516 byte chunks.
|
|
* the NAND controller performs reads/writes with ECC in 516 byte chunks.
|
|
* the driver calls the chunks 'step' or 'codeword' interchangeably
|
|
* the driver calls the chunks 'step' or 'codeword' interchangeably
|
|
-@@ -430,6 +435,13 @@ struct qcom_nand_controller {
|
|
|
|
|
|
+@@ -429,6 +434,13 @@ struct qcom_nand_controller {
|
|
* @cfg0, cfg1, cfg0_raw..: NANDc register configurations needed for
|
|
* @cfg0, cfg1, cfg0_raw..: NANDc register configurations needed for
|
|
* ecc/non-ecc mode for the current nand flash
|
|
* ecc/non-ecc mode for the current nand flash
|
|
* device
|
|
* device
|
|
@@ -42,7 +42,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
*/
|
|
*/
|
|
struct qcom_nand_host {
|
|
struct qcom_nand_host {
|
|
struct nand_chip chip;
|
|
struct nand_chip chip;
|
|
-@@ -452,6 +464,9 @@ struct qcom_nand_host {
|
|
|
|
|
|
+@@ -451,6 +463,9 @@ struct qcom_nand_host {
|
|
u32 ecc_bch_cfg;
|
|
u32 ecc_bch_cfg;
|
|
u32 clrflashstatus;
|
|
u32 clrflashstatus;
|
|
u32 clrreadstatus;
|
|
u32 clrreadstatus;
|
|
@@ -52,7 +52,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
};
|
|
};
|
|
|
|
|
|
/*
|
|
/*
|
|
-@@ -460,12 +475,14 @@ struct qcom_nand_host {
|
|
|
|
|
|
+@@ -459,12 +474,14 @@ struct qcom_nand_host {
|
|
* @ecc_modes - ecc mode for NAND
|
|
* @ecc_modes - ecc mode for NAND
|
|
* @is_bam - whether NAND controller is using BAM
|
|
* @is_bam - whether NAND controller is using BAM
|
|
* @is_qpic - whether NAND CTRL is part of qpic IP
|
|
* @is_qpic - whether NAND CTRL is part of qpic IP
|
|
@@ -67,7 +67,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
u32 dev_cmd_reg_start;
|
|
u32 dev_cmd_reg_start;
|
|
};
|
|
};
|
|
|
|
|
|
-@@ -1604,7 +1621,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *
|
|
|
|
|
|
+@@ -1603,7 +1620,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *
|
|
data_size1 = mtd->writesize - host->cw_size * (ecc->steps - 1);
|
|
data_size1 = mtd->writesize - host->cw_size * (ecc->steps - 1);
|
|
oob_size1 = host->bbm_size;
|
|
oob_size1 = host->bbm_size;
|
|
|
|
|
|
@@ -76,7 +76,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
data_size2 = ecc->size - data_size1 -
|
|
data_size2 = ecc->size - data_size1 -
|
|
((ecc->steps - 1) * 4);
|
|
((ecc->steps - 1) * 4);
|
|
oob_size2 = (ecc->steps * 4) + host->ecc_bytes_hw +
|
|
oob_size2 = (ecc->steps * 4) + host->ecc_bytes_hw +
|
|
-@@ -1685,7 +1702,7 @@ check_for_erased_page(struct qcom_nand_h
|
|
|
|
|
|
+@@ -1684,7 +1701,7 @@ check_for_erased_page(struct qcom_nand_h
|
|
}
|
|
}
|
|
|
|
|
|
for_each_set_bit(cw, &uncorrectable_cws, ecc->steps) {
|
|
for_each_set_bit(cw, &uncorrectable_cws, ecc->steps) {
|
|
@@ -85,7 +85,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
data_size = ecc->size - ((ecc->steps - 1) * 4);
|
|
data_size = ecc->size - ((ecc->steps - 1) * 4);
|
|
oob_size = (ecc->steps * 4) + host->ecc_bytes_hw;
|
|
oob_size = (ecc->steps * 4) + host->ecc_bytes_hw;
|
|
} else {
|
|
} else {
|
|
-@@ -1844,7 +1861,7 @@ static int read_page_ecc(struct qcom_nan
|
|
|
|
|
|
+@@ -1843,7 +1860,7 @@ static int read_page_ecc(struct qcom_nan
|
|
for (i = 0; i < ecc->steps; i++) {
|
|
for (i = 0; i < ecc->steps; i++) {
|
|
int data_size, oob_size;
|
|
int data_size, oob_size;
|
|
|
|
|
|
@@ -94,7 +94,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
data_size = ecc->size - ((ecc->steps - 1) << 2);
|
|
data_size = ecc->size - ((ecc->steps - 1) << 2);
|
|
oob_size = (ecc->steps << 2) + host->ecc_bytes_hw +
|
|
oob_size = (ecc->steps << 2) + host->ecc_bytes_hw +
|
|
host->spare_bytes;
|
|
host->spare_bytes;
|
|
-@@ -1941,6 +1958,30 @@ static int copy_last_cw(struct qcom_nand
|
|
|
|
|
|
+@@ -1940,6 +1957,30 @@ static int copy_last_cw(struct qcom_nand
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -125,7 +125,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
/* implements ecc->read_page() */
|
|
/* implements ecc->read_page() */
|
|
static int qcom_nandc_read_page(struct nand_chip *chip, uint8_t *buf,
|
|
static int qcom_nandc_read_page(struct nand_chip *chip, uint8_t *buf,
|
|
int oob_required, int page)
|
|
int oob_required, int page)
|
|
-@@ -1949,6 +1990,9 @@ static int qcom_nandc_read_page(struct n
|
|
|
|
|
|
+@@ -1948,6 +1989,9 @@ static int qcom_nandc_read_page(struct n
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
u8 *data_buf, *oob_buf = NULL;
|
|
u8 *data_buf, *oob_buf = NULL;
|
|
|
|
|
|
@@ -135,7 +135,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
nand_read_page_op(chip, page, 0, NULL, 0);
|
|
nand_read_page_op(chip, page, 0, NULL, 0);
|
|
data_buf = buf;
|
|
data_buf = buf;
|
|
oob_buf = oob_required ? chip->oob_poi : NULL;
|
|
oob_buf = oob_required ? chip->oob_poi : NULL;
|
|
-@@ -1968,6 +2012,9 @@ static int qcom_nandc_read_page_raw(stru
|
|
|
|
|
|
+@@ -1967,6 +2011,9 @@ static int qcom_nandc_read_page_raw(stru
|
|
int cw, ret;
|
|
int cw, ret;
|
|
u8 *data_buf = buf, *oob_buf = chip->oob_poi;
|
|
u8 *data_buf = buf, *oob_buf = chip->oob_poi;
|
|
|
|
|
|
@@ -145,7 +145,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
for (cw = 0; cw < ecc->steps; cw++) {
|
|
for (cw = 0; cw < ecc->steps; cw++) {
|
|
ret = qcom_nandc_read_cw_raw(mtd, chip, data_buf, oob_buf,
|
|
ret = qcom_nandc_read_cw_raw(mtd, chip, data_buf, oob_buf,
|
|
page, cw);
|
|
page, cw);
|
|
-@@ -1988,6 +2035,9 @@ static int qcom_nandc_read_oob(struct na
|
|
|
|
|
|
+@@ -1987,6 +2034,9 @@ static int qcom_nandc_read_oob(struct na
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
|
|
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
|
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
|
|
|
|
|
@@ -155,7 +155,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
clear_read_regs(nandc);
|
|
clear_read_regs(nandc);
|
|
clear_bam_transaction(nandc);
|
|
clear_bam_transaction(nandc);
|
|
|
|
|
|
-@@ -2008,6 +2058,9 @@ static int qcom_nandc_write_page(struct
|
|
|
|
|
|
+@@ -2007,6 +2057,9 @@ static int qcom_nandc_write_page(struct
|
|
u8 *data_buf, *oob_buf;
|
|
u8 *data_buf, *oob_buf;
|
|
int i, ret;
|
|
int i, ret;
|
|
|
|
|
|
@@ -165,7 +165,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
nand_prog_page_begin_op(chip, page, 0, NULL, 0);
|
|
nand_prog_page_begin_op(chip, page, 0, NULL, 0);
|
|
|
|
|
|
clear_read_regs(nandc);
|
|
clear_read_regs(nandc);
|
|
-@@ -2023,7 +2076,7 @@ static int qcom_nandc_write_page(struct
|
|
|
|
|
|
+@@ -2022,7 +2075,7 @@ static int qcom_nandc_write_page(struct
|
|
for (i = 0; i < ecc->steps; i++) {
|
|
for (i = 0; i < ecc->steps; i++) {
|
|
int data_size, oob_size;
|
|
int data_size, oob_size;
|
|
|
|
|
|
@@ -174,7 +174,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
data_size = ecc->size - ((ecc->steps - 1) << 2);
|
|
data_size = ecc->size - ((ecc->steps - 1) << 2);
|
|
oob_size = (ecc->steps << 2) + host->ecc_bytes_hw +
|
|
oob_size = (ecc->steps << 2) + host->ecc_bytes_hw +
|
|
host->spare_bytes;
|
|
host->spare_bytes;
|
|
-@@ -2080,6 +2133,9 @@ static int qcom_nandc_write_page_raw(str
|
|
|
|
|
|
+@@ -2079,6 +2132,9 @@ static int qcom_nandc_write_page_raw(str
|
|
u8 *data_buf, *oob_buf;
|
|
u8 *data_buf, *oob_buf;
|
|
int i, ret;
|
|
int i, ret;
|
|
|
|
|
|
@@ -184,7 +184,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
nand_prog_page_begin_op(chip, page, 0, NULL, 0);
|
|
nand_prog_page_begin_op(chip, page, 0, NULL, 0);
|
|
clear_read_regs(nandc);
|
|
clear_read_regs(nandc);
|
|
clear_bam_transaction(nandc);
|
|
clear_bam_transaction(nandc);
|
|
-@@ -2098,7 +2154,7 @@ static int qcom_nandc_write_page_raw(str
|
|
|
|
|
|
+@@ -2097,7 +2153,7 @@ static int qcom_nandc_write_page_raw(str
|
|
data_size1 = mtd->writesize - host->cw_size * (ecc->steps - 1);
|
|
data_size1 = mtd->writesize - host->cw_size * (ecc->steps - 1);
|
|
oob_size1 = host->bbm_size;
|
|
oob_size1 = host->bbm_size;
|
|
|
|
|
|
@@ -193,7 +193,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
data_size2 = ecc->size - data_size1 -
|
|
data_size2 = ecc->size - data_size1 -
|
|
((ecc->steps - 1) << 2);
|
|
((ecc->steps - 1) << 2);
|
|
oob_size2 = (ecc->steps << 2) + host->ecc_bytes_hw +
|
|
oob_size2 = (ecc->steps << 2) + host->ecc_bytes_hw +
|
|
-@@ -2158,6 +2214,9 @@ static int qcom_nandc_write_oob(struct n
|
|
|
|
|
|
+@@ -2157,6 +2213,9 @@ static int qcom_nandc_write_oob(struct n
|
|
int data_size, oob_size;
|
|
int data_size, oob_size;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
@@ -203,7 +203,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
host->use_ecc = true;
|
|
host->use_ecc = true;
|
|
clear_bam_transaction(nandc);
|
|
clear_bam_transaction(nandc);
|
|
|
|
|
|
-@@ -2806,6 +2865,7 @@ static int qcom_nand_host_init_and_regis
|
|
|
|
|
|
+@@ -2805,6 +2864,7 @@ static int qcom_nand_host_init_and_regis
|
|
struct nand_chip *chip = &host->chip;
|
|
struct nand_chip *chip = &host->chip;
|
|
struct mtd_info *mtd = nand_to_mtd(chip);
|
|
struct mtd_info *mtd = nand_to_mtd(chip);
|
|
struct device *dev = nandc->dev;
|
|
struct device *dev = nandc->dev;
|
|
@@ -211,7 +211,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
ret = of_property_read_u32(dn, "reg", &host->cs);
|
|
ret = of_property_read_u32(dn, "reg", &host->cs);
|
|
-@@ -2866,6 +2926,17 @@ static int qcom_nand_host_init_and_regis
|
|
|
|
|
|
+@@ -2865,6 +2925,17 @@ static int qcom_nand_host_init_and_regis
|
|
if (ret)
|
|
if (ret)
|
|
nand_cleanup(chip);
|
|
nand_cleanup(chip);
|
|
|
|
|
|
@@ -229,7 +229,7 @@ Signed-off-by: Ansuel Smith <[email protected]>
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-@@ -3032,6 +3103,7 @@ static int qcom_nandc_remove(struct plat
|
|
|
|
|
|
+@@ -3030,6 +3101,7 @@ static int qcom_nandc_remove(struct plat
|
|
static const struct qcom_nandc_props ipq806x_nandc_props = {
|
|
static const struct qcom_nandc_props ipq806x_nandc_props = {
|
|
.ecc_modes = (ECC_RS_4BIT | ECC_BCH_8BIT),
|
|
.ecc_modes = (ECC_RS_4BIT | ECC_BCH_8BIT),
|
|
.is_bam = false,
|
|
.is_bam = false,
|