diff mbox series

[RFC,18/18] mtd: spi-nor: Make sure the 8D-8D-8D can be selected on mx25uw51245g

Message ID 20181012084825.23697-19-boris.brezillon@bootlin.com (mailing list archive)
State New, archived
Headers show
Series mtd: spi-nor: Proposal for 8-8-8 mode support | expand

Commit Message

Boris Brezillon Oct. 12, 2018, 8:48 a.m. UTC
mx25uw51245g support 8D-8D-8D mode. Patch the macronix_opi_change_mode()
and macronix_opi_tweak_params() functions to support this mode.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

Comments

Boris Brezillon Jan. 14, 2019, 8:39 a.m. UTC | #1
On Mon, 14 Jan 2019 15:30:29 +0800
masonccyang@mxic.com.tw wrote:

> Hi Boris,
> 
> I have patched direct mapping in spi-nor.c layer based on 
> your direct mapping mode's patch [1][2] as attached file,
> spi-nor-mxic.patch.
> 
> 
> 
> 
> The read performance has got much improvement in direct mapping
> read mode w/ 8D-8D-8D DDR@25MHz compare to manual I/O mode.
> i.e,.
> 62.8 KB/s(manual I/O) is up to 21.8 MB/s(direct mapping read).
> 
> Looking forward to this direct mapping mode would be merged to mainline 
> soon. 
> 
> thanks & best regards,
> Mason
> 
> [1] https://patchwork.kernel.org/patch/10670753
> [2] https://patchwork.kernel.org/patch/10670747 

Those 2 patches have been applied already, we only miss [3] which I plan
to queue for v5.1.

[3]http://patchwork.ozlabs.org/patch/993805/
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index d961e3a7b500..e8bd807b7520 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1709,6 +1709,10 @@  static int macronix_opi_change_mode(struct spi_nor *nor,
 		val |= CR2_REG0_MODE_OPI_STR;
 		break;
 
+	case SPI_NOR_MODE_OPI_FULL_DTR:
+		val |= CR2_REG0_MODE_OPI_DTR;
+		break;
+
 	default:
 		/*
 		 * If we reach that point, there's a serious problem in the
@@ -1732,7 +1736,11 @@  static void macronix_opi_adjust_op(struct spi_nor *nor, struct spi_mem_op *op)
 	case SPINOR_OP_READ_4B:
 	case SPINOR_OP_READ_FAST_4B:
 		op->dummy.nbytes = 20;
-		op->cmd.opcode = 0xec;
+		if (nor->mode == SPI_NOR_MODE_OPI_FULL_DTR)
+			op->cmd.opcode = 0xee;
+		else
+			op->cmd.opcode = 0xec;
+
 		break;
 
 	case SPINOR_OP_PP:
@@ -1781,8 +1789,11 @@  static void macronix_opi_adjust_op(struct spi_nor *nor, struct spi_mem_op *op)
 	if (op->addr.nbytes)
 		op->addr.buswidth = 8;
 
-	if (op->dummy.nbytes)
+	if (op->dummy.nbytes) {
 		op->dummy.buswidth = 8;
+		if (op->dummy.dtr)
+			op->dummy.nbytes *= 2;
+	}
 
 	if (op->data.buswidth)
 		op->data.buswidth = 8;
@@ -1805,6 +1816,14 @@  static void macronix_opi_tweak_params(struct spi_nor *nor,
 	spi_nor_set_pp_settings(&params->page_programs[SNOR_CMD_PP_8_8_8],
 				0x12ed,
 				SNOR_PROTO_8_8_8 | SNOR_PROTO_INST_2BYTE);
+
+	params->hwcaps.mask |= SNOR_HWCAPS_OPI_FULL_DTR;
+	spi_nor_set_read_settings(&params->reads[SNOR_CMD_READ_8D_8D_8D],
+				  0, 20, 0xee11,
+				  SNOR_PROTO_8D_8D_8D | SNOR_PROTO_INST_2BYTE);
+	spi_nor_set_pp_settings(&params->page_programs[SNOR_CMD_PP_8D_8D_8D],
+				0x12ed,
+				SNOR_PROTO_8D_8D_8D | SNOR_PROTO_INST_2BYTE);
 }
 
 /* Used when the "_ext_id" is two bytes at most */