Skip to content

Commit 913bf8d

Browse files
juhosgbroonie
authored andcommitted
spi: spi-qpic-snand: add support for 8 bits ECC strength
Even though the hardware supports 8 bits ECC strength, but that is not handled in the driver yet. This change adds the missing bits in order to allow using the driver with chips which require 8 bits ECC strength. No functional changes intended with regard to the existing 4 bits ECC strength support. Tested on an IPQ9574 platform using a GigaDevice GD5F2GM7REYIG chip. Signed-off-by: Gabor Juhos <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 0dc7e65 commit 913bf8d

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

drivers/spi/spi-qpic-snand.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,22 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)
277277
goto err_free_ecc_cfg;
278278
}
279279

280-
if (ecc_cfg->strength != 4) {
280+
switch (ecc_cfg->strength) {
281+
case 4:
282+
ecc_cfg->ecc_mode = ECC_MODE_4BIT;
283+
ecc_cfg->ecc_bytes_hw = 7;
284+
ecc_cfg->spare_bytes = 4;
285+
break;
286+
287+
case 8:
288+
ecc_cfg->ecc_mode = ECC_MODE_8BIT;
289+
ecc_cfg->ecc_bytes_hw = 13;
290+
ecc_cfg->spare_bytes = 2;
291+
break;
292+
293+
default:
281294
dev_err(snandc->dev,
282-
"only 4 bits ECC strength is supported\n");
295+
"only 4 or 8 bits ECC strength is supported\n");
283296
ret = -EOPNOTSUPP;
284297
goto err_free_ecc_cfg;
285298
}
@@ -296,8 +309,6 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)
296309
nand->ecc.ctx.priv = ecc_cfg;
297310
snandc->qspi->mtd = mtd;
298311

299-
ecc_cfg->ecc_bytes_hw = 7;
300-
ecc_cfg->spare_bytes = 4;
301312
ecc_cfg->bbm_size = 1;
302313
ecc_cfg->bch_enabled = true;
303314
ecc_cfg->bytes = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes + ecc_cfg->bbm_size;
@@ -343,7 +354,7 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)
343354
FIELD_PREP(ECC_SW_RESET, 0) |
344355
FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, ecc_cfg->cw_data) |
345356
FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) |
346-
FIELD_PREP(ECC_MODE_MASK, ECC_MODE_4BIT) |
357+
FIELD_PREP(ECC_MODE_MASK, ecc_cfg->ecc_mode) |
347358
FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, ecc_cfg->ecc_bytes_hw);
348359

349360
ecc_cfg->ecc_buf_cfg = FIELD_PREP(NUM_STEPS_MASK, 0x203);

0 commit comments

Comments
 (0)