Unverified Commit 51106b83 authored by Mark Brown's avatar Mark Brown
Browse files

spi: spi-qpic-snand: enable 8 bits ECC strength

Merge series from Gabor Juhos <j4g8y7@gmail.com>:

This small patch set adds support for 8 bits ECC strength, which widens
the range of the usable SPI NAND chips with the driver.

The first one is a preparatory patch which adds some defines which
allows to avoid using magic values, and the second patch implements
the actual support.

The series should be integrated via the SPI tree, as that contains
prerequisite changes.
parents 7105fdd5 913bf8d5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1379,7 +1379,7 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
	int cwperpage, bad_block_byte, ret;
	bool wide_bus;
	int ecc_mode = 1;
	int ecc_mode = ECC_MODE_8BIT;

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

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

			if (wide_bus) {
				host->ecc_bytes_hw = 8;
+16 −5
Original line number Diff line number Diff line
@@ -277,9 +277,22 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)
		goto err_free_ecc_cfg;
	}

	if (ecc_cfg->strength != 4) {
	switch (ecc_cfg->strength) {
	case 4:
		ecc_cfg->ecc_mode = ECC_MODE_4BIT;
		ecc_cfg->ecc_bytes_hw = 7;
		ecc_cfg->spare_bytes = 4;
		break;

	case 8:
		ecc_cfg->ecc_mode = ECC_MODE_8BIT;
		ecc_cfg->ecc_bytes_hw = 13;
		ecc_cfg->spare_bytes = 2;
		break;

	default:
		dev_err(snandc->dev,
			"only 4 bits ECC strength is supported\n");
			"only 4 or 8 bits ECC strength is supported\n");
		ret = -EOPNOTSUPP;
		goto err_free_ecc_cfg;
	}
@@ -296,8 +309,6 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)
	nand->ecc.ctx.priv = ecc_cfg;
	snandc->qspi->mtd = mtd;

	ecc_cfg->ecc_bytes_hw = 7;
	ecc_cfg->spare_bytes = 4;
	ecc_cfg->bbm_size = 1;
	ecc_cfg->bch_enabled = true;
	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)
			       FIELD_PREP(ECC_SW_RESET, 0) |
			       FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, ecc_cfg->cw_data) |
			       FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) |
			       FIELD_PREP(ECC_MODE_MASK, 0) |
			       FIELD_PREP(ECC_MODE_MASK, ecc_cfg->ecc_mode) |
			       FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, ecc_cfg->ecc_bytes_hw);

	ecc_cfg->ecc_buf_cfg = FIELD_PREP(NUM_STEPS_MASK, 0x203);
+2 −0
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@
#define	ECC_SW_RESET			BIT(1)
#define	ECC_MODE			4
#define	ECC_MODE_MASK			GENMASK(5, 4)
#define	ECC_MODE_4BIT			0
#define	ECC_MODE_8BIT			1
#define	ECC_PARITY_SIZE_BYTES_BCH	8
#define	ECC_PARITY_SIZE_BYTES_BCH_MASK	GENMASK(12, 8)
#define	ECC_NUM_DATA_BYTES		16