Skip to content

Commit 0dc7e65

Browse files
juhosgbroonie
authored andcommitted
mtd: nand: qpic-common: add defines for ECC_MODE values
Add defines for the values of the ECC_MODE field of the NAND_DEV0_ECC_CFG register and change both the 'qcom-nandc' and 'spi-qpic-snand' drivers to use those instead of magic numbers. No functional changes. This is in preparation for adding 8 bit ECC strength support for the 'spi-qpic-snand' driver. Reviewed-by: Md Sadre Alam <[email protected]> Signed-off-by: Gabor Juhos <[email protected]> Acked-by: Miquel Raynal <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d2c0e95 commit 0dc7e65

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

drivers/mtd/nand/raw/qcom_nandc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
13791379
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
13801380
int cwperpage, bad_block_byte, ret;
13811381
bool wide_bus;
1382-
int ecc_mode = 1;
1382+
int ecc_mode = ECC_MODE_8BIT;
13831383

13841384
/* controller only supports 512 bytes data steps */
13851385
ecc->size = NANDC_STEP_SIZE;
@@ -1400,7 +1400,7 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
14001400
if (ecc->strength >= 8) {
14011401
/* 8 bit ECC defaults to BCH ECC on all platforms */
14021402
host->bch_enabled = true;
1403-
ecc_mode = 1;
1403+
ecc_mode = ECC_MODE_8BIT;
14041404

14051405
if (wide_bus) {
14061406
host->ecc_bytes_hw = 14;
@@ -1420,7 +1420,7 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
14201420
if (nandc->props->ecc_modes & ECC_BCH_4BIT) {
14211421
/* BCH */
14221422
host->bch_enabled = true;
1423-
ecc_mode = 0;
1423+
ecc_mode = ECC_MODE_4BIT;
14241424

14251425
if (wide_bus) {
14261426
host->ecc_bytes_hw = 8;

drivers/spi/spi-qpic-snand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)
343343
FIELD_PREP(ECC_SW_RESET, 0) |
344344
FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, ecc_cfg->cw_data) |
345345
FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) |
346-
FIELD_PREP(ECC_MODE_MASK, 0) |
346+
FIELD_PREP(ECC_MODE_MASK, ECC_MODE_4BIT) |
347347
FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, ecc_cfg->ecc_bytes_hw);
348348

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

include/linux/mtd/nand-qpic-common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
#define ECC_SW_RESET BIT(1)
102102
#define ECC_MODE 4
103103
#define ECC_MODE_MASK GENMASK(5, 4)
104+
#define ECC_MODE_4BIT 0
105+
#define ECC_MODE_8BIT 1
104106
#define ECC_PARITY_SIZE_BYTES_BCH 8
105107
#define ECC_PARITY_SIZE_BYTES_BCH_MASK GENMASK(12, 8)
106108
#define ECC_NUM_DATA_BYTES 16

0 commit comments

Comments
 (0)