* [PATCH v7 0/7] Add octal DTR support for Macronix flash
@ 2023-12-21 9:06 Jaime Liao
2023-12-21 9:06 ` [PATCH v7 1/7] mtd: spi-nor: add Octal " Jaime Liao
` (6 more replies)
0 siblings, 7 replies; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:06 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
Add method for Macronix Octal DTR Eable/Disable.
Merge Tudor's patch "Allow specifying the byte order in DTR mode"
Add support for Macronix flash
v7:
Add dtr_swab16 judgement to enable/disable Macronix xSPI host
controller swap byte feature.
v6:
Add byte swap support for spi-mxic.c
Remove flash name in ID table.
v5:
Remove manufacturer read id function.
For increased readability, separate Flash IDs based on whether
it supports RWW feature.
v4:
Add patch for adding manufacturer read id function.
remove patch "hook manufacturer by checking first byte id"
v3:
Add patch for hook manufacturer by comparing ID 1st byte.
Add patches for specifying the byte order in DTR mode by merging
Tudor's patch.
v2:
Following exsting rules to re-create Macronix specify Octal DTR method.
change signature to jaimeliao@mxic.com.tw
Clear sector size information in flash INFO.
JaimeLiao (7):
mtd: spi-nor: add Octal DTR support for Macronix flash
spi: spi-mem: Allow specifying the byte order in DTR mode
mtd: spi-nor: core: Allow specifying the byte order in DTR mode
mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT
spi: mxic: Add support for swapping byte
mtd: spi-nor: add support for Macronix Octal flash with RWW feature
mtd: spi-nor: add support for Macronix Octal flash
drivers/mtd/spi-nor/core.c | 8 ++
drivers/mtd/spi-nor/core.h | 1 +
drivers/mtd/spi-nor/macronix.c | 166 +++++++++++++++++++++++++++++++++
drivers/mtd/spi-nor/sfdp.c | 4 +
drivers/mtd/spi-nor/sfdp.h | 1 +
drivers/spi/spi-mem.c | 4 +
drivers/spi/spi-mxic.c | 19 +++-
include/linux/spi/spi-mem.h | 6 ++
8 files changed, 205 insertions(+), 4 deletions(-)
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v7 1/7] mtd: spi-nor: add Octal DTR support for Macronix flash
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
@ 2023-12-21 9:06 ` Jaime Liao
2024-01-05 13:12 ` Michael Walle
2024-01-12 8:10 ` Tudor Ambarus
2023-12-21 9:06 ` [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode Jaime Liao
` (5 subsequent siblings)
6 siblings, 2 replies; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:06 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
Create Macronix specify method for enable Octal DTR mode and
set 20 dummy cycles to allow running at the maximum supported
frequency for Macronix Octal flash.
Use number of dummy cycles which is parse by SFDP then convert
it to bit pattern and set in CR2 register.
Set CR2 register for enable octal DTR mode.
Use Read ID to confirm that enabling/diabling octal DTR mode
was successful.
Macronix ID format is A-A-B-B-C-C in octal DTR mode.
To ensure the successful enablement of octal DTR mode, confirm
that the 6-byte data is entirely correct.
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
Co-developed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/mtd/spi-nor/macronix.c | 100 +++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index ea6be95e75a5..dee71776b1a8 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -8,6 +8,24 @@
#include "core.h"
+#define SPINOR_OP_MXIC_RD_ANY_REG 0x71 /* Read volatile configuration register 2 */
+#define SPINOR_OP_MXIC_WR_ANY_REG 0x72 /* Write volatile configuration register 2 */
+#define SPINOR_REG_MXIC_CR2_MODE 0x00000000 /* CR2 address for setting octal DTR mode */
+#define SPINOR_REG_MXIC_CR2_DC 0x00000300 /* CR2 address for setting dummy cycles */
+#define SPINOR_REG_MXIC_OPI_DTR_EN 0x2 /* Enable Octal DTR */
+#define SPINOR_REG_MXIC_SPI_EN 0x0 /* Enable SPI */
+#define SPINOR_REG_MXIC_ADDR_BYTES 4 /* Fixed R/W volatile address bytes to 4 */
+/* Convert dummy cycles to bit pattern */
+#define SPINOR_REG_MXIC_DC(p) \
+ ((20 - p)/2)
+
+/* Macronix SPI NOR flash operations. */
+#define MXIC_NOR_WR_ANY_REG_OP(naddr, addr, ndata, buf) \
+ SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_MXIC_WR_ANY_REG, 0), \
+ SPI_MEM_OP_ADDR(naddr, addr, 0), \
+ SPI_MEM_OP_NO_DUMMY, \
+ SPI_MEM_OP_DATA_OUT(ndata, buf, 0))
+
static int
mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
const struct sfdp_parameter_header *bfpt_header,
@@ -185,6 +203,87 @@ static const struct flash_info macronix_nor_parts[] = {
}
};
+static int macronix_nor_octal_dtr_en(struct spi_nor *nor)
+{
+ struct spi_mem_op op;
+ u8 *buf = nor->bouncebuf, i;
+ int ret;
+
+ /* Use dummy cycles which is parse by SFDP and convert to bit pattern. */
+ buf[0] = SPINOR_REG_MXIC_DC(nor->params->reads[SNOR_CMD_READ_8_8_8_DTR].num_wait_states);
+ op = (struct spi_mem_op)
+ MXIC_NOR_WR_ANY_REG_OP(SPINOR_REG_MXIC_ADDR_BYTES,
+ SPINOR_REG_MXIC_CR2_DC, 1, buf);
+
+ ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto);
+ if (ret)
+ return ret;
+
+ /* Set the octal and DTR enable bits. */
+ buf[0] = SPINOR_REG_MXIC_OPI_DTR_EN;
+ op = (struct spi_mem_op)
+ MXIC_NOR_WR_ANY_REG_OP(SPINOR_REG_MXIC_ADDR_BYTES,
+ SPINOR_REG_MXIC_CR2_MODE, 1, buf);
+ ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto);
+ if (ret)
+ return ret;
+
+ /* Read flash ID to make sure the switch was successful. */
+ ret = spi_nor_read_id(nor, 4, 4, buf, SNOR_PROTO_8_8_8_DTR);
+ if (ret) {
+ dev_dbg(nor->dev, "error %d reading JEDEC ID after enabling 8D-8D-8D mode\n", ret);
+ return ret;
+ }
+
+ /* Macronix SPI-NOR flash 8D-8D-8D read ID would get 6 bytes data A-A-B-B-C-C */
+ for (i = 0; i < nor->info->id->len; i++)
+ if (buf[i * 2] != buf[(i * 2) + 1] ||
+ buf[i * 2] != nor->info->id->bytes[i])
+ return -EINVAL;
+
+ return 0;
+}
+
+static int macronix_nor_octal_dtr_dis(struct spi_nor *nor)
+{
+ struct spi_mem_op op;
+ u8 *buf = nor->bouncebuf;
+ int ret;
+
+ /*
+ * The register is 1-byte wide, but 1-byte transactions are not
+ * allowed in 8D-8D-8D mode. Since there is no register at the
+ * next location, just initialize the value to 0 and let the
+ * transaction go on.
+ */
+ buf[0] = SPINOR_REG_MXIC_SPI_EN;
+ buf[1] = 0x0;
+ op = (struct spi_mem_op)
+ MXIC_NOR_WR_ANY_REG_OP(SPINOR_REG_MXIC_ADDR_BYTES,
+ SPINOR_REG_MXIC_CR2_MODE, 2, buf);
+ ret = spi_nor_write_any_volatile_reg(nor, &op, SNOR_PROTO_8_8_8_DTR);
+ if (ret)
+ return ret;
+
+ /* Read flash ID to make sure the switch was successful. */
+ ret = spi_nor_read_id(nor, 0, 0, buf, SNOR_PROTO_1_1_1);
+ if (ret) {
+ dev_dbg(nor->dev, "error %d reading JEDEC ID after disabling 8D-8D-8D mode\n", ret);
+ return ret;
+ }
+
+ if (memcmp(buf, nor->info->id->bytes, nor->info->id->len))
+ return -EINVAL;
+
+ return 0;
+}
+
+static int macronix_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
+{
+ return enable ? macronix_nor_octal_dtr_en(nor) :
+ macronix_nor_octal_dtr_dis(nor);
+}
+
static void macronix_nor_default_init(struct spi_nor *nor)
{
nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable;
@@ -194,6 +293,7 @@ static int macronix_nor_late_init(struct spi_nor *nor)
{
if (!nor->params->set_4byte_addr_mode)
nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode_en4b_ex4b;
+ nor->params->set_octal_dtr = macronix_nor_set_octal_dtr;
return 0;
}
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
2023-12-21 9:06 ` [PATCH v7 1/7] mtd: spi-nor: add Octal " Jaime Liao
@ 2023-12-21 9:06 ` Jaime Liao
2024-01-05 12:48 ` Michael Walle
` (2 more replies)
2023-12-21 9:06 ` [PATCH v7 3/7] mtd: spi-nor: core: " Jaime Liao
` (4 subsequent siblings)
6 siblings, 3 replies; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:06 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
There are NOR flashes (Macronix) that swap the bytes on a 16-bit
boundary when configured in Octal DTR mode. The byte order of
16-bit words is swapped when read or written in Octal Double
Transfer Rate (DTR) mode compared to Single Transfer Rate (STR)
modes. If one writes D0 D1 D2 D3 bytes using 1-1-1 mode, and uses
8D-8D-8D SPI mode for reading, it will read back D1 D0 D3 D2.
Swapping the bytes may introduce some endianness problems. It can
affect the boot sequence if the entire boot sequence is not handled
in either 8D-8D-8D mode or 1-1-1 mode. So we must swap the bytes
back to have the same byte order as in STR modes. Fortunately there
are controllers that could swap the bytes back at runtime,
addressing the flash's endiannesses requirements. Provide a way for
the upper layers to specify the byte order in Octal DTR mode.
Merge Tudor's patch and add modifications for suiting newer version
of Linux kernel.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
drivers/spi/spi-mem.c | 4 ++++
include/linux/spi/spi-mem.h | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index edd7430d4c05..9c03b5617fff 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -172,6 +172,10 @@ bool spi_mem_default_supports_op(struct spi_mem *mem,
if (!spi_mem_controller_is_capable(ctlr, dtr))
return false;
+ if (op->data.dtr_swab16 &&
+ !(spi_mem_controller_is_capable(ctlr, dtr_swab16)))
+ return false;
+
if (op->cmd.nbytes != 2)
return false;
} else {
diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
index 6b0a7dc48a4b..d4935c5c3c7a 100644
--- a/include/linux/spi/spi-mem.h
+++ b/include/linux/spi/spi-mem.h
@@ -89,6 +89,8 @@ enum spi_mem_data_dir {
* @dummy.dtr: whether the dummy bytes should be sent in DTR mode or not
* @data.buswidth: number of IO lanes used to send/receive the data
* @data.dtr: whether the data should be sent in DTR mode or not
+ * @data.dtr_swab16: whether the byte order of 16-bit words is swapped when read
+ * or written in Octal DTR mode compared to STR mode.
* @data.ecc: whether error correction is required or not
* @data.dir: direction of the transfer
* @data.nbytes: number of data bytes to send/receive. Can be zero if the
@@ -123,6 +125,7 @@ struct spi_mem_op {
struct {
u8 buswidth;
u8 dtr : 1;
+ u8 dtr_swab16 : 1;
u8 ecc : 1;
u8 __pad : 6;
enum spi_mem_data_dir dir;
@@ -294,10 +297,13 @@ struct spi_controller_mem_ops {
/**
* struct spi_controller_mem_caps - SPI memory controller capabilities
* @dtr: Supports DTR operations
+ * @dtr_swab16: Supports swapping bytes on a 16 bit boundary when configured in
+ * Octal DTR
* @ecc: Supports operations with error correction
*/
struct spi_controller_mem_caps {
bool dtr;
+ bool dtr_swab16;
bool ecc;
};
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v7 3/7] mtd: spi-nor: core: Allow specifying the byte order in DTR mode
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
2023-12-21 9:06 ` [PATCH v7 1/7] mtd: spi-nor: add Octal " Jaime Liao
2023-12-21 9:06 ` [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode Jaime Liao
@ 2023-12-21 9:06 ` Jaime Liao
2024-01-05 12:59 ` Michael Walle
2024-01-12 8:31 ` Tudor Ambarus
2023-12-21 9:06 ` [PATCH v7 4/7] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT Jaime Liao
` (3 subsequent siblings)
6 siblings, 2 replies; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:06 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
Macronix swaps bytes on a 16-bit boundary when configured in Octal DTR.
The byte order of 16-bit words is swapped when read or written in 8D-8D-8D
mode compared to STR modes. Allow operations to specify the byte order in
DTR mode, so that controllers can swap the bytes back at run-time to
address the flash's endianness requirements, if they are capable. If the
controllers are not capable of swapping the bytes, the protocol is
downgrade via spi_nor_spimem_adjust_hwcaps(). When available, the swapping
of the bytes is always done regardless if it's a data or register access,
so that we comply with the JESD216 requirements: "Byte order of 16-bit
words is swapped when read in 8D-8D-8D mode compared to 1-1-1".
Merge Tudor's patch and add modifications for suiting newer version
of Linux kernel.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
drivers/mtd/spi-nor/core.c | 8 ++++++++
drivers/mtd/spi-nor/core.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 1c443fe568cf..f659dd037a25 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -70,6 +70,13 @@ static u8 spi_nor_get_cmd_ext(const struct spi_nor *nor,
}
}
+static inline bool spi_nor_is_octal_dtr_swab16(const struct spi_nor *nor,
+ enum spi_nor_protocol proto)
+{
+ return (proto == SNOR_PROTO_8_8_8_DTR) &&
+ (nor->flags & SNOR_F_DTR_SWAB16);
+}
+
/**
* spi_nor_spimem_setup_op() - Set up common properties of a spi-mem op.
* @nor: pointer to a 'struct spi_nor'
@@ -105,6 +112,7 @@ void spi_nor_spimem_setup_op(const struct spi_nor *nor,
op->addr.dtr = true;
op->dummy.dtr = true;
op->data.dtr = true;
+ op->data.dtr_swab16 = spi_nor_is_octal_dtr_swab16(nor, proto);
/* 2 bytes per clock cycle in DTR mode. */
op->dummy.nbytes *= 2;
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 93cd2fc3606d..fe1259b32110 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -140,6 +140,7 @@ enum spi_nor_option_flags {
SNOR_F_RWW = BIT(14),
SNOR_F_ECC = BIT(15),
SNOR_F_NO_WP = BIT(16),
+ SNOR_F_DTR_SWAB16 = BIT(17),
};
struct spi_nor_read_command {
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v7 4/7] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
` (2 preceding siblings ...)
2023-12-21 9:06 ` [PATCH v7 3/7] mtd: spi-nor: core: " Jaime Liao
@ 2023-12-21 9:06 ` Jaime Liao
2024-01-05 13:02 ` Michael Walle
2023-12-21 9:07 ` [PATCH v7 5/7] spi: mxic: Add support for swapping byte Jaime Liao
` (2 subsequent siblings)
6 siblings, 1 reply; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:06 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
Parse BFPT in order to retrieve the byte order in 8D-8D-8D mode.
This info flag will be used as a basis to determine whether
there is byte swapping of data for SPI NOR flash in octal
DTR mode.
The controller driver will check whether byte swapping is supported
to determin whether the corresponding operation are supported, thus
avoiding the generation of unexpected data order.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
drivers/mtd/spi-nor/sfdp.c | 4 ++++
drivers/mtd/spi-nor/sfdp.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index b3b11dfed789..2241207556bf 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -650,6 +650,10 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
return -EOPNOTSUPP;
}
+ /* Byte order in 8D-8D-8D mode */
+ if (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_BYTE_ORDER_SWAPPED)
+ nor->flags |= SNOR_F_DTR_SWAB16;
+
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
}
diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h
index 6eb99e1cdd61..eba760941d43 100644
--- a/drivers/mtd/spi-nor/sfdp.h
+++ b/drivers/mtd/spi-nor/sfdp.h
@@ -123,6 +123,7 @@ struct sfdp_bfpt {
#define BFPT_DWORD18_CMD_EXT_INV (0x1UL << 29) /* Invert */
#define BFPT_DWORD18_CMD_EXT_RES (0x2UL << 29) /* Reserved */
#define BFPT_DWORD18_CMD_EXT_16B (0x3UL << 29) /* 16-bit opcode */
+#define BFPT_DWORD18_BYTE_ORDER_SWAPPED BIT(31) /* Byte order of 16-bit words in 8D-8D-8D mode */
struct sfdp_parameter_header {
u8 id_lsb;
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v7 5/7] spi: mxic: Add support for swapping byte
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
` (3 preceding siblings ...)
2023-12-21 9:06 ` [PATCH v7 4/7] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT Jaime Liao
@ 2023-12-21 9:07 ` Jaime Liao
2024-01-05 12:37 ` Michael Walle
2023-12-21 9:07 ` [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature Jaime Liao
2023-12-21 9:07 ` [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash Jaime Liao
6 siblings, 1 reply; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:07 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
Some SPI-NOR flash swap the bytes on a 16-bit boundary when
configured in Octal DTR mode. It means data format D0 D1 D2 D3
would be swapped to D1 D0 D3 D2. So that whether controller
support swapping bytes should be checked before enable Octal
DTR mode. Add swap byte support on a 16-bit boundary when
configured in Octal DTR mode for Macronix xSPI host controller
dirver.
According dtr_swab in operation to enable/disable Macronix
xSPI host controller swap byte feature.
To make sure swap byte feature is working well, program data in
1S-1S-1S mode then read back and compare read data in 8D-8D-8D
mode.
This feature have been validated on byte-swap flash and
non-byte-swap flash.
Macronix xSPI host controller bit "HC_CFG_DATA_PASS" determine
the byte swap feature disabled/enabled and swap byte feature is
working on 8D-8D-8D mode only.
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
drivers/spi/spi-mxic.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c
index 60c9f3048ac9..8dc83adaaa88 100644
--- a/drivers/spi/spi-mxic.c
+++ b/drivers/spi/spi-mxic.c
@@ -294,7 +294,8 @@ static void mxic_spi_hw_init(struct mxic_spi *mxic)
mxic->regs + HC_CFG);
}
-static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags)
+static u32 mxic_spi_prep_hc_cfg(const struct spi_mem_op *op,
+ struct spi_device *spi, u32 flags)
{
int nio = 1;
@@ -305,6 +306,13 @@ static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags)
else if (spi->mode & (SPI_TX_DUAL | SPI_RX_DUAL))
nio = 2;
+ if (op->data.dtr) {
+ if (op->data.dtr_swab16)
+ flags &= ~HC_CFG_DATA_PASS;
+ else
+ flags |= HC_CFG_DATA_PASS;
+ }
+
return flags | HC_CFG_NIO(nio) |
HC_CFG_TYPE(spi_get_chipselect(spi, 0), HC_CFG_TYPE_SPI_NOR) |
HC_CFG_SLV_ACT(spi_get_chipselect(spi, 0)) | HC_CFG_IDLE_SIO_LVL(1);
@@ -397,7 +405,8 @@ static ssize_t mxic_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
if (WARN_ON(offs + desc->info.offset + len > U32_MAX))
return -EINVAL;
- writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG);
+ writel(mxic_spi_prep_hc_cfg(&desc->info.op_tmpl,
+ desc->mem->spi, 0), mxic->regs + HC_CFG);
writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len),
mxic->regs + LRD_CFG);
@@ -441,7 +450,8 @@ static ssize_t mxic_spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc,
if (WARN_ON(offs + desc->info.offset + len > U32_MAX))
return -EINVAL;
- writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG);
+ writel(mxic_spi_prep_hc_cfg(&desc->info.op_tmpl,
+ desc->mem->spi, 0), mxic->regs + HC_CFG);
writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len),
mxic->regs + LWR_CFG);
@@ -518,7 +528,7 @@ static int mxic_spi_mem_exec_op(struct spi_mem *mem,
if (ret)
return ret;
- writel(mxic_spi_prep_hc_cfg(mem->spi, HC_CFG_MAN_CS_EN),
+ writel(mxic_spi_prep_hc_cfg(op, mem->spi, HC_CFG_MAN_CS_EN),
mxic->regs + HC_CFG);
writel(HC_EN_BIT, mxic->regs + HC_EN);
@@ -572,6 +582,7 @@ static const struct spi_controller_mem_ops mxic_spi_mem_ops = {
static const struct spi_controller_mem_caps mxic_spi_mem_caps = {
.dtr = true,
+ .dtr_swab16 = true,
.ecc = true,
};
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
` (4 preceding siblings ...)
2023-12-21 9:07 ` [PATCH v7 5/7] spi: mxic: Add support for swapping byte Jaime Liao
@ 2023-12-21 9:07 ` Jaime Liao
2024-01-05 13:07 ` Michael Walle
2024-01-12 8:42 ` Tudor Ambarus
2023-12-21 9:07 ` [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash Jaime Liao
6 siblings, 2 replies; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:07 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
Adding Macronix Octal flash for Octal DTR support.
The octaflash series can be divided into the following types:
MX25 series : Serial NOR Flash.
MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb)
LM/UM series : Up to 250MHz clock frequency with both DTR/STR operation.
LW/UW series : Support simultaneous Read-while-Write operation in multiple
bank architecture. Read-while-write feature which means read
data one bank while another bank is programing or erasing.
MX25LM : 3.0V Octal I/O
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf
MX25UM : 1.8V Octal I/O
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8967/MX25UM51245G,%201.8V,%20512Mb,%20v1.5.pdf
MX66LM : 3.0V Octal I/O with stacked die
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8748/MX66LM1G45G,%203V,%201Gb,%20v1.1.pdf
MX66UM : 1.8V Octal I/O with stacked die
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8711/MX66UM1G45G,%201.8V,%201Gb,%20v1.1.pdf
MX25LW : 3.0V Octal I/O with Read-while-Write
MX25UW : 1.8V Octal I/O with Read-while-Write
MX66LW : 3.0V Octal I/O with Read-while-Write and stack die
MX66UW : 1.8V Octal I/O with Read-while-Write and stack die
As below are the SFDP table dump.
zynq> cat jedec_id
c28437
zynq> cat manufacturer
macronix
zynq> cat partname
mx25uw6345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0300ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200c4cc04674630b030b0f4bdd55c
000000ff101000200000000000007c234800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043060f0021dcffff
zynq> md5sum sfdp
c6fb57b8fdd4c35b5f0dacc4a1f7d4f4 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 8388608 (8M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28137
zynq> cat manufacturer
macronix
zynq> cat partname
mx25uw6445g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0300ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200c4cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043060f0021dcffff
zynq> md5sum sfdp
b09aeedb0cfd0f77adc7e08592d295a9 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 8388608 (8M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28438
zynq> cat manufacturer
macronix
zynq> cat partname
mx25uw12345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0700ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200c9cc04674630b030b0f4bdd55c
000000ff101000200000000000007c234800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043060f0021dcffff
zynq> md5sum sfdp
a3eb609c08894c84270ad06efc03766c sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 16777216 (16M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28138
zynq> cat manufacturer
macronix
zynq> cat partname
mx25uw12845g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff000000000000000000000000
00000000e5208affffffff0700ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200c9cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043060f0021dcffff
zynq> md5sum sfdp
9eacff90d7aa7cf737b970e0f2a7f2c6 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 16777216 (16M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28439
zynq> cat manufacturer
macronix
zynq> cat partname
mx25uw25345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200d2cc04674630b030b0f4bdd55c
000000ff101000200000147c00007c234800000000008888000000000000
00400fd1fff30fd1fff300050090060500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000000000000000
0000000000000000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043061f0021dcffff
zynq> md5sum sfdp
765e310356fb92fdd77b2af1c725fbcb sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28139
zynq> cat manufacturer
macronix
zynq> cat partname
mx25uw25645g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200d2cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043060f0021dcffff
zynq> md5sum sfdp
e43ab2dbcbcf99cebc74964c5dcf3ee2 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28639
zynq> cat manufacturer
macronix
zynq> cat partname
mx25lw25645g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200d2cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
b5db9fe24f814b5cc6a392c4c56ed331 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2843a
zynq> cat manufacturer
macronix
zynq> cat partname
mx25uw51345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c
000000ff101000200000147c00007c234800000000008888000000000000
00400fd1fff30fd1fff300050090060500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000000000000000
0000000000000000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043061f0021dcffff
zynq> md5sum sfdp
b3c82acb473b65117fe0c063be9d8546 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 67108864 (64M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2863a
zynq> cat manufacturer
macronix
zynq> cat partname
mx25lw51245g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff000000000000000000000000
00000000e5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
bb32ccaca6814f3104b985ac91bd65ac sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 67108864 (64M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2843b
zynq> cat manufacturer
macronix
zynq> cat partname
mx66uw1g345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c
000000ff101000200000147c00007c234800000000008888000000000000
00400fd1fff30fd1fff300050090060500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000000000000000
0000000000000000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043061f0021dcffff
zynq> md5sum sfdp
dd3ef0a8d22ee81fc5bccdcb67dee6ca sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 134217728 (128M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2813b
zynq> cat manufacturer
macronix
zynq> cat partname
mx66uw1g45g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043060f0021dcffff
zynq> md5sum sfdp
b89a53266007fce06ba7cc4c0956f917 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 134217728 (128M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2843c
zynq> cat manufacturer
macronix
zynq> cat partname
mx66uw2g345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff7f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87790100841200e2cc04674630b030b0f4bdd55c
000000ff101000200000147c00007c234800000000007777000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000000001445988043061f0021dcffff
zynq> md5sum sfdp
00447475e039e67c256a8d75d5885ae8 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 268435456 (256M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2943c
zynq> cat manufacturer
macronix
zynq> cat partname
mx66uw2g345gx0
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff7f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87790100841200e2cc04674630b030b0f4bdd55c
000000ff101000200000087c00007c234800000000008888000000000000
00400fd1fff30fd1fff300050090060500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000000000000000
0000000000000000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a00001445988043061f0021dcffff
zynq> md5sum sfdp
e6226263b999578a2f034ea969988d7f sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 268435456 (256M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
drivers/mtd/spi-nor/macronix.c | 52 ++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index dee71776b1a8..29bd5f0b32ec 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -200,6 +200,58 @@ static const struct flash_info macronix_nor_parts[] = {
.name = "mx25l3255e",
.size = SZ_4M,
.no_sfdp_flags = SECT_4K,
+ }, {
+ .id = SNOR_ID(0xc2, 0x84, 0x37),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x81, 0x37),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x84, 0x38),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x81, 0x38),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x84, 0x39),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x81, 0x39),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x86, 0x39),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x84, 0x3a),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x86, 0x3a),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x84, 0x3b),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x81, 0x3b),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x84, 0x3c),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x94, 0x3c),
+ .n_banks = 4,
+ .flags = SPI_NOR_RWW,
}
};
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
` (5 preceding siblings ...)
2023-12-21 9:07 ` [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature Jaime Liao
@ 2023-12-21 9:07 ` Jaime Liao
2024-01-05 13:11 ` Michael Walle
2024-01-12 8:44 ` Tudor Ambarus
6 siblings, 2 replies; 27+ messages in thread
From: Jaime Liao @ 2023-12-21 9:07 UTC (permalink / raw)
To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
Cc: leoyu, jaimeliao
From: JaimeLiao <jaimeliao@mxic.com.tw>
Adding Macronix Octal flash for Octal DTR support.
The octaflash series can be divided into the following types:
MX25 series : Serial NOR Flash.
MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb)
LM/UM series : Up to 250MHz clock frequency with both DTR/STR operation.
LW/UW series : Support simultaneous Read-while-Write operation in multiple
bank architecture. Read-while-write feature which means read
data one bank while another bank is programing or erasing.
MX25LM : 3.0V Octal I/O
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf
MX25UM : 1.8V Octal I/O
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8967/MX25UM51245G,%201.8V,%20512Mb,%20v1.5.pdf
MX66LM : 3.0V Octal I/O with stacked die
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8748/MX66LM1G45G,%203V,%201Gb,%20v1.1.pdf
MX66UM : 1.8V Octal I/O with stacked die
-https://www.mxic.com.tw/Lists/Datasheet/Attachments/8711/MX66UM1G45G,%201.8V,%201Gb,%20v1.1.pdf
MX25LW : 3.0V Octal I/O with Read-while-Write
MX25UW : 1.8V Octal I/O with Read-while-Write
MX66LW : 3.0V Octal I/O with Read-while-Write and stack die
MX66UW : 1.8V Octal I/O with Read-while-Write and stack die
As below are the SFDP table dump.
zynq> cat jedec_id
c28339
zynq> cat manufacturer
macronix
zynq> cat partname
mx25um25345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87690100821200d2cc02673830b030b0f4bdd55c
000000ff101000200000000000007c234800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
040900001445988043060f0021dcffff
zynq> md5sum sfdp
950e623745a002e1747008592e6dbdf9 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28039
zynq> cat manufacturer
macronix
zynq> cat partname
mx25um25645g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87790100841200d2cc02673830b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a000014359c8043060f0021dcffff
zynq> md5sum sfdp
d652779f17770dc833cd96262cb2a620 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c28539
zynq> cat manufacturer
macronix
zynq> cat partname
mx25lm25645g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87690100821200d2cc02673830b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
ec258f831ac737454c7eb9f6a8a4495a sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2803a
zynq> cat manufacturer
macronix
zynq> cat partname
mx25um51245g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a000014359c8043060f0021dcffff
zynq> md5sum sfdp
75d81c1eb2fd2767634f1d0dfbb3be35 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 67108864 (64M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2853a
zynq> cat manufacturer
macronix
zynq> cat partname
mx25lm51245g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200e2cc02674430b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
214868617d74e6bfb2c45444d5d6fff0 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 67108864 (64M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2803b
zynq> cat manufacturer
macronix
zynq> cat partname
mx66um1g45g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200e2cc02674430b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a000014359c8043060f0021dcffff
zynq> md5sum sfdp
eea09d64679e64f627402b39a177e356 sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 134217728 (128M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
zynq> cat jedec_id
c2853b
zynq> cat manufacturer
macronix
zynq> cat partname
mx66lm1g45g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87690100821200e2cc02673830b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
7b46113b529d58a6335531a10f14a76e sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 134217728 (128M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
drivers/mtd/spi-nor/macronix.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index 29bd5f0b32ec..04d4ed6c1245 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -252,6 +252,20 @@ static const struct flash_info macronix_nor_parts[] = {
.id = SNOR_ID(0xc2, 0x94, 0x3c),
.n_banks = 4,
.flags = SPI_NOR_RWW,
+ }, {
+ .id = SNOR_ID(0xc2, 0x83, 0x39),
+ }, {
+ .id = SNOR_ID(0xc2, 0x80, 0x39),
+ }, {
+ .id = SNOR_ID(0xc2, 0x85, 0x39),
+ }, {
+ .id = SNOR_ID(0xc2, 0x80, 0x3a),
+ }, {
+ .id = SNOR_ID(0xc2, 0x85, 0x3a),
+ }, {
+ .id = SNOR_ID(0xc2, 0x80, 0x3b),
+ }, {
+ .id = SNOR_ID(0xc2, 0x85, 0x3b),
}
};
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v7 5/7] spi: mxic: Add support for swapping byte
2023-12-21 9:07 ` [PATCH v7 5/7] spi: mxic: Add support for swapping byte Jaime Liao
@ 2024-01-05 12:37 ` Michael Walle
2024-01-12 5:14 ` liao jaime
0 siblings, 1 reply; 27+ messages in thread
From: Michael Walle @ 2024-01-05 12:37 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
Hi,
> Some SPI-NOR flash swap the bytes on a 16-bit boundary when
> configured in Octal DTR mode. It means data format D0 D1 D2 D3
> would be swapped to D1 D0 D3 D2. So that whether controller
> support swapping bytes should be checked before enable Octal
> DTR mode. Add swap byte support on a 16-bit boundary when
> configured in Octal DTR mode for Macronix xSPI host controller
> dirver.
>
> According dtr_swab in operation to enable/disable Macronix
> xSPI host controller swap byte feature.
>
> To make sure swap byte feature is working well, program data in
> 1S-1S-1S mode then read back and compare read data in 8D-8D-8D
> mode.
>
> This feature have been validated on byte-swap flash and
> non-byte-swap flash.
>
> Macronix xSPI host controller bit "HC_CFG_DATA_PASS" determine
> the byte swap feature disabled/enabled and swap byte feature is
> working on 8D-8D-8D mode only.
>
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> ---
> drivers/spi/spi-mxic.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c
> index 60c9f3048ac9..8dc83adaaa88 100644
> --- a/drivers/spi/spi-mxic.c
> +++ b/drivers/spi/spi-mxic.c
> @@ -294,7 +294,8 @@ static void mxic_spi_hw_init(struct mxic_spi *mxic)
> mxic->regs + HC_CFG);
> }
>
> -static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags)
> +static u32 mxic_spi_prep_hc_cfg(const struct spi_mem_op *op,
> + struct spi_device *spi, u32 flags)
Not my driver, but because it caught my eye: I wouldn't pass
spi_mem_op. Maybe just "bool swap16"?
> {
> int nio = 1;
>
> @@ -305,6 +306,13 @@ static u32 mxic_spi_prep_hc_cfg(struct spi_device
> *spi, u32 flags)
> else if (spi->mode & (SPI_TX_DUAL | SPI_RX_DUAL))
> nio = 2;
>
> + if (op->data.dtr) {
Checking this seems to be redundant with checking dtr_swab16.
> + if (op->data.dtr_swab16)
> + flags &= ~HC_CFG_DATA_PASS;
> + else
> + flags |= HC_CFG_DATA_PASS;
Mhh, this is strange. Given that dtr_swap16 is a new flag means
that you are now setting the HC_CFG_DATA_PASS bit by default.
Something to keep in mind if you have any users which already use
8d8d8d mode nowadays.
Also clearing the flag seems superfluous.
-michael
> + }
> +
> return flags | HC_CFG_NIO(nio) |
> HC_CFG_TYPE(spi_get_chipselect(spi, 0), HC_CFG_TYPE_SPI_NOR) |
> HC_CFG_SLV_ACT(spi_get_chipselect(spi, 0)) |
> HC_CFG_IDLE_SIO_LVL(1);
> @@ -397,7 +405,8 @@ static ssize_t mxic_spi_mem_dirmap_read(struct
> spi_mem_dirmap_desc *desc,
> if (WARN_ON(offs + desc->info.offset + len > U32_MAX))
> return -EINVAL;
>
> - writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG);
> + writel(mxic_spi_prep_hc_cfg(&desc->info.op_tmpl,
> + desc->mem->spi, 0), mxic->regs + HC_CFG);
>
> writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len),
> mxic->regs + LRD_CFG);
> @@ -441,7 +450,8 @@ static ssize_t mxic_spi_mem_dirmap_write(struct
> spi_mem_dirmap_desc *desc,
> if (WARN_ON(offs + desc->info.offset + len > U32_MAX))
> return -EINVAL;
>
> - writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG);
> + writel(mxic_spi_prep_hc_cfg(&desc->info.op_tmpl,
> + desc->mem->spi, 0), mxic->regs + HC_CFG);
>
> writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len),
> mxic->regs + LWR_CFG);
> @@ -518,7 +528,7 @@ static int mxic_spi_mem_exec_op(struct spi_mem
> *mem,
> if (ret)
> return ret;
>
> - writel(mxic_spi_prep_hc_cfg(mem->spi, HC_CFG_MAN_CS_EN),
> + writel(mxic_spi_prep_hc_cfg(op, mem->spi, HC_CFG_MAN_CS_EN),
> mxic->regs + HC_CFG);
>
> writel(HC_EN_BIT, mxic->regs + HC_EN);
> @@ -572,6 +582,7 @@ static const struct spi_controller_mem_ops
> mxic_spi_mem_ops = {
>
> static const struct spi_controller_mem_caps mxic_spi_mem_caps = {
> .dtr = true,
> + .dtr_swab16 = true,
> .ecc = true,
> };
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode
2023-12-21 9:06 ` [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode Jaime Liao
@ 2024-01-05 12:48 ` Michael Walle
2024-01-12 8:29 ` Tudor Ambarus
2024-01-05 13:02 ` Michael Walle
2024-01-12 8:15 ` Tudor Ambarus
2 siblings, 1 reply; 27+ messages in thread
From: Michael Walle @ 2024-01-05 12:48 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
Hi,
> There are NOR flashes (Macronix) that swap the bytes on a 16-bit
> boundary when configured in Octal DTR mode. The byte order of
> 16-bit words is swapped when read or written in Octal Double
> Transfer Rate (DTR) mode compared to Single Transfer Rate (STR)
> modes. If one writes D0 D1 D2 D3 bytes using 1-1-1 mode, and uses
> 8D-8D-8D SPI mode for reading, it will read back D1 D0 D3 D2.
> Swapping the bytes may introduce some endianness problems. It can
> affect the boot sequence if the entire boot sequence is not handled
> in either 8D-8D-8D mode or 1-1-1 mode. So we must swap the bytes
> back to have the same byte order as in STR modes. Fortunately there
> are controllers that could swap the bytes back at runtime,
> addressing the flash's endiannesses requirements. Provide a way for
> the upper layers to specify the byte order in Octal DTR mode.
>
> Merge Tudor's patch and add modifications for suiting newer version
> of Linux kernel.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> ---
> drivers/spi/spi-mem.c | 4 ++++
> include/linux/spi/spi-mem.h | 6 ++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index edd7430d4c05..9c03b5617fff 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -172,6 +172,10 @@ bool spi_mem_default_supports_op(struct spi_mem
> *mem,
> if (!spi_mem_controller_is_capable(ctlr, dtr))
> return false;
>
> + if (op->data.dtr_swab16 &&
> + !(spi_mem_controller_is_capable(ctlr, dtr_swab16)))
unnecessary parentheses.
> + return false;
> +
> if (op->cmd.nbytes != 2)
> return false;
> } else {
> diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
> index 6b0a7dc48a4b..d4935c5c3c7a 100644
> --- a/include/linux/spi/spi-mem.h
> +++ b/include/linux/spi/spi-mem.h
> @@ -89,6 +89,8 @@ enum spi_mem_data_dir {
> * @dummy.dtr: whether the dummy bytes should be sent in DTR mode or
> not
> * @data.buswidth: number of IO lanes used to send/receive the data
> * @data.dtr: whether the data should be sent in DTR mode or not
> + * @data.dtr_swab16: whether the byte order of 16-bit words is swapped
> when read
> + * or written in Octal DTR mode compared to STR mode.
maybe just swap16? I'm not sure. Doesn't really apply to DTR, because
it is not a thing for 4bit DTR for example. Just for 8d8d8d and "faster"
because there you transmit more than one byte in one clock cycle.
"whether bytes within a 16-bit word should be swapped. Some flashes will
swap the data in 8D mode. In that case, this should be set to true
to instruct the controller to swap the data back on the fly.
> * @data.ecc: whether error correction is required or not
> * @data.dir: direction of the transfer
> * @data.nbytes: number of data bytes to send/receive. Can be zero if
> the
> @@ -123,6 +125,7 @@ struct spi_mem_op {
> struct {
> u8 buswidth;
> u8 dtr : 1;
> + u8 dtr_swab16 : 1;
> u8 ecc : 1;
> u8 __pad : 6;
__pad : 5;
Does anyone know if this is really necessary?
> enum spi_mem_data_dir dir;
> @@ -294,10 +297,13 @@ struct spi_controller_mem_ops {
> /**
> * struct spi_controller_mem_caps - SPI memory controller capabilities
> * @dtr: Supports DTR operations
> + * @dtr_swab16: Supports swapping bytes on a 16 bit boundary when
> configured in
> + * Octal DTR
I guess the same comment as above applies, doesn't really have something
to do with dtr, but only 8d.
-michael
> * @ecc: Supports operations with error correction
> */
> struct spi_controller_mem_caps {
> bool dtr;
> + bool dtr_swab16;
> bool ecc;
> };
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 3/7] mtd: spi-nor: core: Allow specifying the byte order in DTR mode
2023-12-21 9:06 ` [PATCH v7 3/7] mtd: spi-nor: core: " Jaime Liao
@ 2024-01-05 12:59 ` Michael Walle
2024-01-12 5:17 ` liao jaime
2024-01-12 8:31 ` Tudor Ambarus
1 sibling, 1 reply; 27+ messages in thread
From: Michael Walle @ 2024-01-05 12:59 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
Hi,
> Macronix swaps bytes on a 16-bit boundary when configured in Octal DTR.
> The byte order of 16-bit words is swapped when read or written in
> 8D-8D-8D
> mode compared to STR modes. Allow operations to specify the byte order
> in
> DTR mode, so that controllers can swap the bytes back at run-time to
> address the flash's endianness requirements, if they are capable. If
> the
> controllers are not capable of swapping the bytes, the protocol is
> downgrade via spi_nor_spimem_adjust_hwcaps(). When available, the
> swapping
> of the bytes is always done regardless if it's a data or register
> access,
> so that we comply with the JESD216 requirements: "Byte order of 16-bit
> words is swapped when read in 8D-8D-8D mode compared to 1-1-1".
>
> Merge Tudor's patch and add modifications for suiting newer version
> of Linux kernel.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> ---
> drivers/mtd/spi-nor/core.c | 8 ++++++++
> drivers/mtd/spi-nor/core.h | 1 +
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 1c443fe568cf..f659dd037a25 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -70,6 +70,13 @@ static u8 spi_nor_get_cmd_ext(const struct spi_nor
> *nor,
> }
> }
>
> +static inline bool spi_nor_is_octal_dtr_swab16(const struct spi_nor
> *nor,
> + enum spi_nor_protocol proto)
> +{
> + return (proto == SNOR_PROTO_8_8_8_DTR) &&
> + (nor->flags & SNOR_F_DTR_SWAB16);
> +}
> +
> /**
> * spi_nor_spimem_setup_op() - Set up common properties of a spi-mem
> op.
> * @nor: pointer to a 'struct spi_nor'
> @@ -105,6 +112,7 @@ void spi_nor_spimem_setup_op(const struct spi_nor
> *nor,
> op->addr.dtr = true;
> op->dummy.dtr = true;
> op->data.dtr = true;
> + op->data.dtr_swab16 = spi_nor_is_octal_dtr_swab16(nor, proto);
Just use
dtr_swap16 = nor->flags & SNOR_F_DTR_SWAP16;
Again, I don't really like DTR_SWAP16. JESD216 just mention swapping for
8d8d8d. Depends on how generic we want to go. I'd go with swap16 and
mention
that for now, it is only applicable if data.buswidth == 8 and
data.dtr == true.
-michael
> /* 2 bytes per clock cycle in DTR mode. */
> op->dummy.nbytes *= 2;
> diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
> index 93cd2fc3606d..fe1259b32110 100644
> --- a/drivers/mtd/spi-nor/core.h
> +++ b/drivers/mtd/spi-nor/core.h
> @@ -140,6 +140,7 @@ enum spi_nor_option_flags {
> SNOR_F_RWW = BIT(14),
> SNOR_F_ECC = BIT(15),
> SNOR_F_NO_WP = BIT(16),
> + SNOR_F_DTR_SWAB16 = BIT(17),
> };
>
> struct spi_nor_read_command {
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode
2023-12-21 9:06 ` [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode Jaime Liao
2024-01-05 12:48 ` Michael Walle
@ 2024-01-05 13:02 ` Michael Walle
2024-01-12 5:44 ` liao jaime
2024-01-12 8:15 ` Tudor Ambarus
2 siblings, 1 reply; 27+ messages in thread
From: Michael Walle @ 2024-01-05 13:02 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
I've just noticed you didn't include the SPI maintainer nor linux-spi.
Please make sure you run script/get_maintainer.pl on your patches.
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 4/7] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT
2023-12-21 9:06 ` [PATCH v7 4/7] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT Jaime Liao
@ 2024-01-05 13:02 ` Michael Walle
0 siblings, 0 replies; 27+ messages in thread
From: Michael Walle @ 2024-01-05 13:02 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
> Parse BFPT in order to retrieve the byte order in 8D-8D-8D mode.
>
> This info flag will be used as a basis to determine whether
> there is byte swapping of data for SPI NOR flash in octal
> DTR mode.
>
> The controller driver will check whether byte swapping is supported
> to determin whether the corresponding operation are supported, thus
> avoiding the generation of unexpected data order.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
Apart from the naming issue:
Reviewed-by: Michael Walle <mwalle@kernel.org>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature
2023-12-21 9:07 ` [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature Jaime Liao
@ 2024-01-05 13:07 ` Michael Walle
2024-01-12 8:42 ` Tudor Ambarus
1 sibling, 0 replies; 27+ messages in thread
From: Michael Walle @ 2024-01-05 13:07 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
> Adding Macronix Octal flash for Octal DTR support.
Doesn't fit to the subject nor the content of this patch.
> The octaflash series can be divided into the following types:
>
> MX25 series : Serial NOR Flash.
> MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb)
> LM/UM series : Up to 250MHz clock frequency with both DTR/STR
> operation.
> LW/UW series : Support simultaneous Read-while-Write operation in
> multiple
> bank architecture. Read-while-write feature which means
> read
> data one bank while another bank is programing or
> erasing.
>
> MX25LM : 3.0V Octal I/O
>
> -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf
>
> MX25UM : 1.8V Octal I/O
>
> -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8967/MX25UM51245G,%201.8V,%20512Mb,%20v1.5.pdf
>
> MX66LM : 3.0V Octal I/O with stacked die
>
> -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8748/MX66LM1G45G,%203V,%201Gb,%20v1.1.pdf
>
> MX66UM : 1.8V Octal I/O with stacked die
>
> -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8711/MX66UM1G45G,%201.8V,%201Gb,%20v1.1.pdf
Please use Link: tags just before your SoB.
>
> MX25LW : 3.0V Octal I/O with Read-while-Write
> MX25UW : 1.8V Octal I/O with Read-while-Write
> MX66LW : 3.0V Octal I/O with Read-while-Write and stack die
> MX66UW : 1.8V Octal I/O with Read-while-Write and stack die
>
> As below are the SFDP table dump.
Dunno if it was suggested otherwise, but I'd put the dumps
below under the "---".
> zynq> cat jedec_id
...
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash
2023-12-21 9:07 ` [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash Jaime Liao
@ 2024-01-05 13:11 ` Michael Walle
2024-01-12 5:47 ` liao jaime
2024-01-12 8:44 ` Tudor Ambarus
1 sibling, 1 reply; 27+ messages in thread
From: Michael Walle @ 2024-01-05 13:11 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
> + }, {
> + .id = SNOR_ID(0xc2, 0x83, 0x39),
> + }, {
> + .id = SNOR_ID(0xc2, 0x80, 0x39),
> + }, {
> + .id = SNOR_ID(0xc2, 0x85, 0x39),
> + }, {
> + .id = SNOR_ID(0xc2, 0x80, 0x3a),
> + }, {
> + .id = SNOR_ID(0xc2, 0x85, 0x3a),
> + }, {
> + .id = SNOR_ID(0xc2, 0x80, 0x3b),
> + }, {
> + .id = SNOR_ID(0xc2, 0x85, 0x3b),
Should just be:
/* We need the manufacturer fixups. Keep this last. */
{ .id = SNOR_ID(0xc2) }
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 1/7] mtd: spi-nor: add Octal DTR support for Macronix flash
2023-12-21 9:06 ` [PATCH v7 1/7] mtd: spi-nor: add Octal " Jaime Liao
@ 2024-01-05 13:12 ` Michael Walle
2024-01-12 8:10 ` Tudor Ambarus
1 sibling, 0 replies; 27+ messages in thread
From: Michael Walle @ 2024-01-05 13:12 UTC (permalink / raw)
To: Jaime Liao
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
> Create Macronix specify method for enable Octal DTR mode and
> set 20 dummy cycles to allow running at the maximum supported
> frequency for Macronix Octal flash.
>
> Use number of dummy cycles which is parse by SFDP then convert
> it to bit pattern and set in CR2 register.
> Set CR2 register for enable octal DTR mode.
>
> Use Read ID to confirm that enabling/diabling octal DTR mode
> was successful.
>
> Macronix ID format is A-A-B-B-C-C in octal DTR mode.
> To ensure the successful enablement of octal DTR mode, confirm
> that the 6-byte data is entirely correct.
>
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> Co-developed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Acked-by: Michael Walle <mwalle@kernel.org>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 5/7] spi: mxic: Add support for swapping byte
2024-01-05 12:37 ` Michael Walle
@ 2024-01-12 5:14 ` liao jaime
0 siblings, 0 replies; 27+ messages in thread
From: liao jaime @ 2024-01-12 5:14 UTC (permalink / raw)
To: Michael Walle
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
Hi Michael
>
> Hi,
>
> > Some SPI-NOR flash swap the bytes on a 16-bit boundary when
> > configured in Octal DTR mode. It means data format D0 D1 D2 D3
> > would be swapped to D1 D0 D3 D2. So that whether controller
> > support swapping bytes should be checked before enable Octal
> > DTR mode. Add swap byte support on a 16-bit boundary when
> > configured in Octal DTR mode for Macronix xSPI host controller
> > dirver.
> >
> > According dtr_swab in operation to enable/disable Macronix
> > xSPI host controller swap byte feature.
> >
> > To make sure swap byte feature is working well, program data in
> > 1S-1S-1S mode then read back and compare read data in 8D-8D-8D
> > mode.
> >
> > This feature have been validated on byte-swap flash and
> > non-byte-swap flash.
> >
> > Macronix xSPI host controller bit "HC_CFG_DATA_PASS" determine
> > the byte swap feature disabled/enabled and swap byte feature is
> > working on 8D-8D-8D mode only.
> >
> > Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> > ---
> > drivers/spi/spi-mxic.c | 19 +++++++++++++++----
> > 1 file changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c
> > index 60c9f3048ac9..8dc83adaaa88 100644
> > --- a/drivers/spi/spi-mxic.c
> > +++ b/drivers/spi/spi-mxic.c
> > @@ -294,7 +294,8 @@ static void mxic_spi_hw_init(struct mxic_spi *mxic)
> > mxic->regs + HC_CFG);
> > }
> >
> > -static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags)
> > +static u32 mxic_spi_prep_hc_cfg(const struct spi_mem_op *op,
> > + struct spi_device *spi, u32 flags)
>
> Not my driver, but because it caught my eye: I wouldn't pass
> spi_mem_op. Maybe just "bool swap16"?
Thanks, I will change this next patch.
>
> > {
> > int nio = 1;
> >
> > @@ -305,6 +306,13 @@ static u32 mxic_spi_prep_hc_cfg(struct spi_device
> > *spi, u32 flags)
> > else if (spi->mode & (SPI_TX_DUAL | SPI_RX_DUAL))
> > nio = 2;
> >
> > + if (op->data.dtr) {
>
> Checking this seems to be redundant with checking dtr_swab16.
Got it.
>
> > + if (op->data.dtr_swab16)
> > + flags &= ~HC_CFG_DATA_PASS;
> > + else
> > + flags |= HC_CFG_DATA_PASS;
>
> Mhh, this is strange. Given that dtr_swap16 is a new flag means
> that you are now setting the HC_CFG_DATA_PASS bit by default.
> Something to keep in mind if you have any users which already use
> 8d8d8d mode nowadays.
>
> Also clearing the flag seems superfluous.
>
> -michael
>
> > + }
> > +
> > return flags | HC_CFG_NIO(nio) |
> > HC_CFG_TYPE(spi_get_chipselect(spi, 0), HC_CFG_TYPE_SPI_NOR) |
> > HC_CFG_SLV_ACT(spi_get_chipselect(spi, 0)) |
> > HC_CFG_IDLE_SIO_LVL(1);
> > @@ -397,7 +405,8 @@ static ssize_t mxic_spi_mem_dirmap_read(struct
> > spi_mem_dirmap_desc *desc,
> > if (WARN_ON(offs + desc->info.offset + len > U32_MAX))
> > return -EINVAL;
> >
> > - writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG);
> > + writel(mxic_spi_prep_hc_cfg(&desc->info.op_tmpl,
> > + desc->mem->spi, 0), mxic->regs + HC_CFG);
> >
> > writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len),
> > mxic->regs + LRD_CFG);
> > @@ -441,7 +450,8 @@ static ssize_t mxic_spi_mem_dirmap_write(struct
> > spi_mem_dirmap_desc *desc,
> > if (WARN_ON(offs + desc->info.offset + len > U32_MAX))
> > return -EINVAL;
> >
> > - writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG);
> > + writel(mxic_spi_prep_hc_cfg(&desc->info.op_tmpl,
> > + desc->mem->spi, 0), mxic->regs + HC_CFG);
> >
> > writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len),
> > mxic->regs + LWR_CFG);
> > @@ -518,7 +528,7 @@ static int mxic_spi_mem_exec_op(struct spi_mem
> > *mem,
> > if (ret)
> > return ret;
> >
> > - writel(mxic_spi_prep_hc_cfg(mem->spi, HC_CFG_MAN_CS_EN),
> > + writel(mxic_spi_prep_hc_cfg(op, mem->spi, HC_CFG_MAN_CS_EN),
> > mxic->regs + HC_CFG);
> >
> > writel(HC_EN_BIT, mxic->regs + HC_EN);
> > @@ -572,6 +582,7 @@ static const struct spi_controller_mem_ops
> > mxic_spi_mem_ops = {
> >
> > static const struct spi_controller_mem_caps mxic_spi_mem_caps = {
> > .dtr = true,
> > + .dtr_swab16 = true,
> > .ecc = true,
> > };
Thanks
Jaime
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 3/7] mtd: spi-nor: core: Allow specifying the byte order in DTR mode
2024-01-05 12:59 ` Michael Walle
@ 2024-01-12 5:17 ` liao jaime
0 siblings, 0 replies; 27+ messages in thread
From: liao jaime @ 2024-01-12 5:17 UTC (permalink / raw)
To: Michael Walle
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
Hi Michael
>
> Hi,
>
> > Macronix swaps bytes on a 16-bit boundary when configured in Octal DTR.
> > The byte order of 16-bit words is swapped when read or written in
> > 8D-8D-8D
> > mode compared to STR modes. Allow operations to specify the byte order
> > in
> > DTR mode, so that controllers can swap the bytes back at run-time to
> > address the flash's endianness requirements, if they are capable. If
> > the
> > controllers are not capable of swapping the bytes, the protocol is
> > downgrade via spi_nor_spimem_adjust_hwcaps(). When available, the
> > swapping
> > of the bytes is always done regardless if it's a data or register
> > access,
> > so that we comply with the JESD216 requirements: "Byte order of 16-bit
> > words is swapped when read in 8D-8D-8D mode compared to 1-1-1".
> >
> > Merge Tudor's patch and add modifications for suiting newer version
> > of Linux kernel.
> >
> > Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> > Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> > ---
> > drivers/mtd/spi-nor/core.c | 8 ++++++++
> > drivers/mtd/spi-nor/core.h | 1 +
> > 2 files changed, 9 insertions(+)
> >
> > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> > index 1c443fe568cf..f659dd037a25 100644
> > --- a/drivers/mtd/spi-nor/core.c
> > +++ b/drivers/mtd/spi-nor/core.c
> > @@ -70,6 +70,13 @@ static u8 spi_nor_get_cmd_ext(const struct spi_nor
> > *nor,
> > }
> > }
> >
> > +static inline bool spi_nor_is_octal_dtr_swab16(const struct spi_nor
> > *nor,
> > + enum spi_nor_protocol proto)
> > +{
> > + return (proto == SNOR_PROTO_8_8_8_DTR) &&
> > + (nor->flags & SNOR_F_DTR_SWAB16);
> > +}
> > +
> > /**
> > * spi_nor_spimem_setup_op() - Set up common properties of a spi-mem
> > op.
> > * @nor: pointer to a 'struct spi_nor'
> > @@ -105,6 +112,7 @@ void spi_nor_spimem_setup_op(const struct spi_nor
> > *nor,
> > op->addr.dtr = true;
> > op->dummy.dtr = true;
> > op->data.dtr = true;
> > + op->data.dtr_swab16 = spi_nor_is_octal_dtr_swab16(nor, proto);
>
> Just use
> dtr_swap16 = nor->flags & SNOR_F_DTR_SWAP16;
Got it.
>
> Again, I don't really like DTR_SWAP16. JESD216 just mention swapping for
> 8d8d8d. Depends on how generic we want to go. I'd go with swap16 and
> mention
> that for now, it is only applicable if data.buswidth == 8 and
> data.dtr == true.
>
> -michael
>
> > /* 2 bytes per clock cycle in DTR mode. */
> > op->dummy.nbytes *= 2;
> > diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
> > index 93cd2fc3606d..fe1259b32110 100644
> > --- a/drivers/mtd/spi-nor/core.h
> > +++ b/drivers/mtd/spi-nor/core.h
> > @@ -140,6 +140,7 @@ enum spi_nor_option_flags {
> > SNOR_F_RWW = BIT(14),
> > SNOR_F_ECC = BIT(15),
> > SNOR_F_NO_WP = BIT(16),
> > + SNOR_F_DTR_SWAB16 = BIT(17),
> > };
> >
> > struct spi_nor_read_command {
Thanks
Jaime
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode
2024-01-05 13:02 ` Michael Walle
@ 2024-01-12 5:44 ` liao jaime
0 siblings, 0 replies; 27+ messages in thread
From: liao jaime @ 2024-01-12 5:44 UTC (permalink / raw)
To: Michael Walle
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
Hi Michael
>
> I've just noticed you didn't include the SPI maintainer nor linux-spi.
> Please make sure you run script/get_maintainer.pl on your patches.
Sorry I missed this part.
Thanks for your reminder,
>
> -michael
Thanks
Jaime
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash
2024-01-05 13:11 ` Michael Walle
@ 2024-01-12 5:47 ` liao jaime
0 siblings, 0 replies; 27+ messages in thread
From: liao jaime @ 2024-01-12 5:47 UTC (permalink / raw)
To: Michael Walle
Cc: linux-mtd, tudor.ambarus, pratyush, miquel.raynal, leoyu,
jaimeliao
Hi Michael
>
> > + }, {
> > + .id = SNOR_ID(0xc2, 0x83, 0x39),
> > + }, {
> > + .id = SNOR_ID(0xc2, 0x80, 0x39),
> > + }, {
> > + .id = SNOR_ID(0xc2, 0x85, 0x39),
> > + }, {
> > + .id = SNOR_ID(0xc2, 0x80, 0x3a),
> > + }, {
> > + .id = SNOR_ID(0xc2, 0x85, 0x3a),
> > + }, {
> > + .id = SNOR_ID(0xc2, 0x80, 0x3b),
> > + }, {
> > + .id = SNOR_ID(0xc2, 0x85, 0x3b),
>
> Should just be:
>
> /* We need the manufacturer fixups. Keep this last. */
> { .id = SNOR_ID(0xc2) }
Do you mean I could add this in the last?
Or I need to abandon above ID list?
Sound good.
>
> -michael
Thanks
Jaime
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 1/7] mtd: spi-nor: add Octal DTR support for Macronix flash
2023-12-21 9:06 ` [PATCH v7 1/7] mtd: spi-nor: add Octal " Jaime Liao
2024-01-05 13:12 ` Michael Walle
@ 2024-01-12 8:10 ` Tudor Ambarus
1 sibling, 0 replies; 27+ messages in thread
From: Tudor Ambarus @ 2024-01-12 8:10 UTC (permalink / raw)
To: Jaime Liao, linux-mtd, pratyush, mwalle, miquel.raynal; +Cc: leoyu, jaimeliao
On 12/21/23 09:06, Jaime Liao wrote:
> From: JaimeLiao <jaimeliao@mxic.com.tw>
>
> Create Macronix specify method for enable Octal DTR mode and
> set 20 dummy cycles to allow running at the maximum supported
> frequency for Macronix Octal flash.
>
> Use number of dummy cycles which is parse by SFDP then convert
> it to bit pattern and set in CR2 register.
> Set CR2 register for enable octal DTR mode.
>
> Use Read ID to confirm that enabling/diabling octal DTR mode
> was successful.
>
> Macronix ID format is A-A-B-B-C-C in octal DTR mode.
> To ensure the successful enablement of octal DTR mode, confirm
> that the 6-byte data is entirely correct.
>
> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
> Co-developed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
I'm fine to be added here as co-developer, but you missed to add my
Signed-of-by tag. Please read
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by
before re-submitting.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode
2023-12-21 9:06 ` [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode Jaime Liao
2024-01-05 12:48 ` Michael Walle
2024-01-05 13:02 ` Michael Walle
@ 2024-01-12 8:15 ` Tudor Ambarus
2 siblings, 0 replies; 27+ messages in thread
From: Tudor Ambarus @ 2024-01-12 8:15 UTC (permalink / raw)
To: Jaime Liao, linux-mtd, pratyush, mwalle, miquel.raynal; +Cc: leoyu, jaimeliao
On 12/21/23 09:06, Jaime Liao wrote:
> From: JaimeLiao <jaimeliao@mxic.com.tw>
>
The patch set does not differ from what I sent here
https://patchwork.ozlabs.org/project/linux-mtd/patch/20220311080147.453483-2-tudor.ambarus@microchip.com/
so please keep my authorship and add your Signed-off-by tag and maybe a
[Jaime Liao: describe your changes]
section above your S-o-b tag.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode
2024-01-05 12:48 ` Michael Walle
@ 2024-01-12 8:29 ` Tudor Ambarus
2024-01-12 8:31 ` Michael Walle
0 siblings, 1 reply; 27+ messages in thread
From: Tudor Ambarus @ 2024-01-12 8:29 UTC (permalink / raw)
To: Michael Walle, Jaime Liao
Cc: linux-mtd, pratyush, miquel.raynal, leoyu, jaimeliao
On 1/5/24 12:48, Michael Walle wrote:
> Hi,
>
>> There are NOR flashes (Macronix) that swap the bytes on a 16-bit
>> boundary when configured in Octal DTR mode. The byte order of
>> 16-bit words is swapped when read or written in Octal Double
>> Transfer Rate (DTR) mode compared to Single Transfer Rate (STR)
>> modes. If one writes D0 D1 D2 D3 bytes using 1-1-1 mode, and uses
>> 8D-8D-8D SPI mode for reading, it will read back D1 D0 D3 D2.
>> Swapping the bytes may introduce some endianness problems. It can
>> affect the boot sequence if the entire boot sequence is not handled
>> in either 8D-8D-8D mode or 1-1-1 mode. So we must swap the bytes
>> back to have the same byte order as in STR modes. Fortunately there
>> are controllers that could swap the bytes back at runtime,
>> addressing the flash's endiannesses requirements. Provide a way for
>> the upper layers to specify the byte order in Octal DTR mode.
>>
>> Merge Tudor's patch and add modifications for suiting newer version
>> of Linux kernel.
>>
>> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
>> Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
>> ---
>> drivers/spi/spi-mem.c | 4 ++++
>> include/linux/spi/spi-mem.h | 6 ++++++
>> 2 files changed, 10 insertions(+)
>>
>> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
>> index edd7430d4c05..9c03b5617fff 100644
>> --- a/drivers/spi/spi-mem.c
>> +++ b/drivers/spi/spi-mem.c
>> @@ -172,6 +172,10 @@ bool spi_mem_default_supports_op(struct spi_mem
>> *mem,
>> if (!spi_mem_controller_is_capable(ctlr, dtr))
>> return false;
>>
>> + if (op->data.dtr_swab16 &&
>> + !(spi_mem_controller_is_capable(ctlr, dtr_swab16)))
>
> unnecessary parentheses.
>
>> + return false;
>> +
>> if (op->cmd.nbytes != 2)
>> return false;
>> } else {
>> diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
>> index 6b0a7dc48a4b..d4935c5c3c7a 100644
>> --- a/include/linux/spi/spi-mem.h
>> +++ b/include/linux/spi/spi-mem.h
>> @@ -89,6 +89,8 @@ enum spi_mem_data_dir {
>> * @dummy.dtr: whether the dummy bytes should be sent in DTR mode or not
>> * @data.buswidth: number of IO lanes used to send/receive the data
>> * @data.dtr: whether the data should be sent in DTR mode or not
>> + * @data.dtr_swab16: whether the byte order of 16-bit words is
>> swapped when read
>> + * or written in Octal DTR mode compared to STR mode.
>
> maybe just swap16? I'm not sure. Doesn't really apply to DTR, because
> it is not a thing for 4bit DTR for example. Just for 8d8d8d and "faster"
> because there you transmit more than one byte in one clock cycle.
renaming to swap16 would be good, yes.
>
> "whether bytes within a 16-bit word should be swapped. Some flashes will
> swap the data in 8D mode. In that case, this should be set to true
> to instruct the controller to swap the data back on the fly.
>
>> * @data.ecc: whether error correction is required or not
>> * @data.dir: direction of the transfer
>> * @data.nbytes: number of data bytes to send/receive. Can be zero if
>> the
>> @@ -123,6 +125,7 @@ struct spi_mem_op {
>> struct {
>> u8 buswidth;
>> u8 dtr : 1;
>> + u8 dtr_swab16 : 1;
>> u8 ecc : 1;
>> u8 __pad : 6;
>
> __pad : 5;
>
> Does anyone know if this is really necessary?
>
it's to mitigate a gcc-{12, 13} bug, see
71c8f9cf2623d0db79665f876b95afcdd8214aec
No idea if the bug was fixed in the meantime.
>> enum spi_mem_data_dir dir;
>> @@ -294,10 +297,13 @@ struct spi_controller_mem_ops {
>> /**
>> * struct spi_controller_mem_caps - SPI memory controller capabilities
>> * @dtr: Supports DTR operations
>> + * @dtr_swab16: Supports swapping bytes on a 16 bit boundary when
>> configured in
>> + * Octal DTR
>
> I guess the same comment as above applies, doesn't really have something
> to do with dtr, but only 8d.
OK.
Thanks,
ta
>
> -michael
>
>> * @ecc: Supports operations with error correction
>> */
>> struct spi_controller_mem_caps {
>> bool dtr;
>> + bool dtr_swab16;
>> bool ecc;
>> };
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode
2024-01-12 8:29 ` Tudor Ambarus
@ 2024-01-12 8:31 ` Michael Walle
0 siblings, 0 replies; 27+ messages in thread
From: Michael Walle @ 2024-01-12 8:31 UTC (permalink / raw)
To: Tudor Ambarus
Cc: Jaime Liao, linux-mtd, pratyush, miquel.raynal, leoyu, jaimeliao
>>> * @data.ecc: whether error correction is required or not
>>> * @data.dir: direction of the transfer
>>> * @data.nbytes: number of data bytes to send/receive. Can be zero
>>> if
>>> the
>>> @@ -123,6 +125,7 @@ struct spi_mem_op {
>>> struct {
>>> u8 buswidth;
>>> u8 dtr : 1;
>>> + u8 dtr_swab16 : 1;
>>> u8 ecc : 1;
>>> u8 __pad : 6;
>>
>> __pad : 5;
>>
>> Does anyone know if this is really necessary?
>>
>
> it's to mitigate a gcc-{12, 13} bug, see
> 71c8f9cf2623d0db79665f876b95afcdd8214aec
>
> No idea if the bug was fixed in the meantime.
Ahh right, me of all, should've remembered that ;)
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 3/7] mtd: spi-nor: core: Allow specifying the byte order in DTR mode
2023-12-21 9:06 ` [PATCH v7 3/7] mtd: spi-nor: core: " Jaime Liao
2024-01-05 12:59 ` Michael Walle
@ 2024-01-12 8:31 ` Tudor Ambarus
1 sibling, 0 replies; 27+ messages in thread
From: Tudor Ambarus @ 2024-01-12 8:31 UTC (permalink / raw)
To: Jaime Liao, linux-mtd, pratyush, mwalle, miquel.raynal; +Cc: leoyu, jaimeliao
On 12/21/23 09:06, Jaime Liao wrote:
> From: JaimeLiao <jaimeliao@mxic.com.tw>
Please keep my authorship, as the patch does not differ from what I've
sent at
https://patchwork.ozlabs.org/project/linux-mtd/patch/20220311080147.453483-3-tudor.ambarus@microchip.com/
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature
2023-12-21 9:07 ` [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature Jaime Liao
2024-01-05 13:07 ` Michael Walle
@ 2024-01-12 8:42 ` Tudor Ambarus
1 sibling, 0 replies; 27+ messages in thread
From: Tudor Ambarus @ 2024-01-12 8:42 UTC (permalink / raw)
To: Jaime Liao, linux-mtd, pratyush, mwalle, miquel.raynal; +Cc: leoyu, jaimeliao
On 12/21/23 09:07, Jaime Liao wrote:
> From: JaimeLiao <jaimeliao@mxic.com.tw>
>
> Adding Macronix Octal flash for Octal DTR support.
>
> The octaflash series can be divided into the following types:
>
> MX25 series : Serial NOR Flash.
> MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb)
> LM/UM series : Up to 250MHz clock frequency with both DTR/STR operation.
> LW/UW series : Support simultaneous Read-while-Write operation in multiple
> bank architecture. Read-while-write feature which means read
> data one bank while another bank is programing or erasing.
>
> MX25LM : 3.0V Octal I/O
> -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf
Link: https://blabla just above your S-o-b tag
>
> MX25UM : 1.8V Octal I/O
> -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8967/MX25UM51245G,%201.8V,%20512Mb,%20v1.5.pdf
Please split in 2 patches, one adding MX25{LM, UM} and the other adding
MX66{LM, UM}
Please read
https://www.kernel.org/doc/html/next/driver-api/mtd/spi-nor.html before
re-submitting, you missed the sanity mtd-utils tests.
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash
2023-12-21 9:07 ` [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash Jaime Liao
2024-01-05 13:11 ` Michael Walle
@ 2024-01-12 8:44 ` Tudor Ambarus
1 sibling, 0 replies; 27+ messages in thread
From: Tudor Ambarus @ 2024-01-12 8:44 UTC (permalink / raw)
To: Jaime Liao, linux-mtd, pratyush, mwalle, miquel.raynal; +Cc: leoyu, jaimeliao
same comments as in previous patch
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2024-01-12 8:44 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21 9:06 [PATCH v7 0/7] Add octal DTR support for Macronix flash Jaime Liao
2023-12-21 9:06 ` [PATCH v7 1/7] mtd: spi-nor: add Octal " Jaime Liao
2024-01-05 13:12 ` Michael Walle
2024-01-12 8:10 ` Tudor Ambarus
2023-12-21 9:06 ` [PATCH v7 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode Jaime Liao
2024-01-05 12:48 ` Michael Walle
2024-01-12 8:29 ` Tudor Ambarus
2024-01-12 8:31 ` Michael Walle
2024-01-05 13:02 ` Michael Walle
2024-01-12 5:44 ` liao jaime
2024-01-12 8:15 ` Tudor Ambarus
2023-12-21 9:06 ` [PATCH v7 3/7] mtd: spi-nor: core: " Jaime Liao
2024-01-05 12:59 ` Michael Walle
2024-01-12 5:17 ` liao jaime
2024-01-12 8:31 ` Tudor Ambarus
2023-12-21 9:06 ` [PATCH v7 4/7] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT Jaime Liao
2024-01-05 13:02 ` Michael Walle
2023-12-21 9:07 ` [PATCH v7 5/7] spi: mxic: Add support for swapping byte Jaime Liao
2024-01-05 12:37 ` Michael Walle
2024-01-12 5:14 ` liao jaime
2023-12-21 9:07 ` [PATCH v7 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature Jaime Liao
2024-01-05 13:07 ` Michael Walle
2024-01-12 8:42 ` Tudor Ambarus
2023-12-21 9:07 ` [PATCH v7 7/7] mtd: spi-nor: add support for Macronix Octal flash Jaime Liao
2024-01-05 13:11 ` Michael Walle
2024-01-12 5:47 ` liao jaime
2024-01-12 8:44 ` Tudor Ambarus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox