Skip to contentSkip to conversation

mtd: spi-nor: Add support for Infineon s25hl-t/s25hs-t

PATCH Superseded [email protected] 2 participants 8 messages Feb 21, 2022 – Feb 25, 2022

Subsystems (2)

v8 of 16 Superseded Latest is v16 →

lore
Share & tools
lore
#0 lore raw

v8 cover mtd: spi-nor: Add support for Infineon s25hl-t/s25hs-t

From: Takahiro Kuwano <[email protected]>

The S25HL-T/S25HS-T family is the Infineon SEMPER Flash with Quad SPI.

The datasheets can be found in the following link.
https://www.infineon.com/dgdl/Infineon-S25HS256T_S25HS512T_S25HS01GT_S25HL256T_S25HL512T_S25HL01GT_256-Mb_(32-MB)_512-Mb_(64-MB)_1-Gb_(128-MB)_HS-T_(1.8-V)_HL-T_(3.0-V)_Semper_Flash_with_Quad_SPI-DataSheet-v02_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0ee674b86ee3&da=t

The series depends on:
https://lore.kernel.org/all/[email protected]/T/

Tested on Xilinx Zynq-7000 FPGA board.

Device ID and SFDP dumps:
------------------------------------------------------------
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/partname s25hl512t
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id 342a1a0f0390
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer spansion
zynq> xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 53464450080103ff00000114000100ff84000102500100ff81000116c801 00ff8700011c580100ffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffe720faffffffff1f48eb086b00ff 88bbfeffffffffff00ffffff48eb0c2000ff00ff12d823faff8b82e7ffe3 ec031c608a857a75f766805c8cd6ddfff938f8a1000000000000bc000000 0000f7f5ffff7b920ffe21ffffdc0000800000000000c0ffc3ebc8ffe3eb 00650090060500a10065009600650095716503d0716503d000000000b02e 000088a489aa716503967165039600000000000000000000000000000000 000000000000000000000000000000000000000000000000716505d57165 05d50000a015fc65ff0804008000fc65ff4002008000fd65ff0402008000 fe0002fff1ff0100f8ff0100f8fffb03fe0302fff8fffb03f8ff0100f1ff 0100fe0104fff1ff0000f8ff0200f8fff703f8ff0200f1ff0000ff0400ff f8ffff03
zynq> md5sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 8a0aa90112e154ae3a797df2c211ef61 /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
------------------------------------------------------------

------------------------------------------------------------
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/partname s25hl01gt
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id 342a1b0f0390
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer spansion
zynq> xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 53464450080103ff00000114000100ff84000102500100ff81000116c801 00ff8700011c580100ffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffe720faffffffff3f48eb086b00ff 88bbfeffffffffff00ffffff48eb0c2000ff00ff12d823faff8b82e7ffe6 ec031c608a857a75f766805c8cd6ddfff938f8a1000000000000bc000000 0000f7f5ffff7b920ffe21ffffdc0000800000000000c0ffc3ebc8ffe3eb 00650090060500a10065009600650095716503d0716503d000000000b02e 000088a489aa716503967165039600000000000000000000000000000000 000000000000000000000000000000000000000000000000716505d57165 05d50000a015fc65ff0804008000fc65ff4002008000fd65ff0402008000 fe0002fff1ff0100f8ff0100f8fffb07fe0302fff8fffb07f8ff0100f1ff 0100fe0104fff1ff0000f8ff0200f8fff707f8ff0200f1ff0000ff0400ff f8ffff07
zynq> md5sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 1ad5a0d7d7e0e656986c1e678c416a7e /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
------------------------------------------------------------

------------------------------------------------------------
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/partname s25hs512t
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id 342b1a0f0390
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer spansion
zynq> xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 53464450080103ff00000114000100ff84000102500100ff81000116c801 00ff8700011c580100ffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffe720faffffffff1f48eb086b00ff 88bbfeffffffffff00ffffff48eb0c2000ff00ff12d823faff8b91e8ffe3 ec031c608a857a75f766805c84d6ddfff938f8a100000000000080000000 0000f7f5ffff7b920ffe20ffffd80000800000000000c0ffc3ebc8ffe3eb 00650090060500a10065009600650095716503d0716503d000000000b02e 000088a489aa716503967165039600000000000000000000000000000000 000000000000000000000000000000000000000000000000716505d57165 05d50000ee72fc65ff0804008000fc65ff4002008000fd65ff0402008000 fe0002fff1ff0100f8ff0100f8fffb03fe0302fff8fffb03f8ff0100f1ff 0100fe0104fff1ff0100f8ff0200f8fff703f8ff0200f1ff0100ff0400ff f8ffff03
zynq> md5sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp f17d9e784602187a0933edec3688e30f /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
------------------------------------------------------------

------------------------------------------------------------
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/partname s25hs01gt
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id 342b1b0f0390
zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer spansion
zynq> xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 53464450080103ff00000114000100ff84000102500100ff81000116c801 00ff8700011c580100ffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffe720faffffffff3f48eb086b00ff 88bbfeffffffffff00ffffff48eb0c2000ff00ff12d823faff8b82e7ffe6 ec031c608a857a75f766805c8cd6ddfff938f8a1000000000000bc000000 0000f7f5ffff7b920ffe21ffffdc0000800000000000c0ffc3ebc8ffe3eb 00650090060500a10065009600650095716503d0716503d000000000b02e 000088a489aa716503967165039600000000000000000000000000000000 000000000000000000000000000000000000000000000000716505d57165 05d50000a015fc65ff0804008000fc65ff4002008000fd65ff0402008000 fe0002fff1ff0100f8ff0100f8fffb07fe0302fff8fffb07f8ff0100f1ff 0100fe0104fff1ff0000f8ff0200f8fff707f8ff0200f1ff0000ff0400ff f8ffff07
zynq> md5sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 1ad5a0d7d7e0e656986c1e678c416a7e /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
------------------------------------------------------------

---
Changes in v8:
- Rebase to v5.17-rc4
- Use spi_nor_read_reg and spi_nor_write_reg()

Changes in v7:
- Some changes were missing in v6 patch. Fix it

Changes in v6:
- Remove 2Gb dual die package parts and related changes to split mulit die package support into another series of patches

Changes in v5:
- Fix 'if (ret == 1)' to 'if (ret < 0)' in spansion_read_any_reg()
- Add NO_CHIP_ERASE flag to S25HL02GT and S25HS02GT

Changes in v4:
- Reword 'legacy' to 'default'
- Rename spi_nor_read() to spi_nor_default_ready()
- Fix dummy cycle calculation in spansion_read_any_reg()
- Modify comment for spansion_write_any_reg()
- Merge block comments about SMPT in s25hx_t_post_sfdp_fixups()
- Remove USE_CLSR flags from S25HL02GT and S25HS02GT

Changes in v3:
- Split into multiple patches
- Remove S25HL256T and S25HS256T
- Add S25HL02GT and S25HS02GT
- Add support for multi-die package parts support
- Cleanup Read/Write Any Register implementation
- Remove erase_map fix for top/split sector layout
- Set ECC data unit size (16B) to writesize

Changes in v2:
- Remove SPI_NOR_SKIP_SFDP flag and clean up related fixups
- Check CFR3V[4] to determine page_size instead of force 512B
- Depend on the patchset below to support non-uniform sector layout

    https://lore.kernel.org/linux-mtd/[email protected]/

Takahiro Kuwano (3):
mtd: spi-nor: spansion: Add support for Read Any Register
mtd: spi-nor: spansion: Add support for volatile QE bit
mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups

 drivers/mtd/spi-nor/spansion.c | 169 +++++++++++++++++++++++++++++++++
 1 file changed, 169 insertions(+)
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw

PATCH v8 1/3 mtd: spi-nor: spansion: Add support for Read Any Register

From: Takahiro Kuwano <[email protected]>

The Read Any Register instruction (65h) is followed by register address and dummy cycles, then the selected register byte is returned. This patch adds a spi_mem_op template for that. The spi_mem_op is passed to spi_nor_read_reg() introduced by:
https://lore.kernel.org/linux-mtd/[email protected]/T/#m05d56c77f8d55eb6f3dee4cb138bde4ff390d6c1

---
Changes in v8:
- Remove controller_ops
- Remove spansion_read/write_any_reg()
- Add spi_mem_op macro for Read Any Register

Changes in v7:
- No change

Changes in v6:
- Add helper functions for controller_ops
- Add 'reg_addr_width' parameter to spansion_read/write_any_reg()
- Remove spi_nor_write_enable() from spansion_write_any_reg() and modified function header comment

Changes in v5:
- Fix 'if (ret == 1)' to 'if (ret < 0)' in spansion_read_any_reg()

Changes in v4:
- Fix dummy cycle calculation in spansion_read_any_reg()
- Modify comment for spansion_write_any_reg()

Changes in v3:
- Cleanup implementation

 drivers/mtd/spi-nor/spansion.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/spansion.c +5 -0
index 9bb239f1e142..9040edf7359f 100644
@@ -20,6 +20,11 @@
 #define SPINOR_OP_CYPRESS_RD_FAST		0xee
 
 /* Spansion/Cypress SPI NOR flash operations. */
+#define SPI_NOR_SPANSION_RD_ANY_REG_OP(naddr, addr, ndummy, ndata, buf)	\
+	SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 0),		\
+		   SPI_MEM_OP_ADDR(naddr, addr, 0),			\
+		   SPI_MEM_OP_DUMMY(ndummy, 0),				\
+		   SPI_MEM_OP_DATA_IN(ndata, buf, 0))
 #define SPI_NOR_SPANSION_WR_ANY_REG_OP(naddr, addr, ndata, buf)		\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 0),		\
 		   SPI_MEM_OP_ADDR(naddr, addr, 0),			\
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Reviewed-by on v8 1/3
#2 lore raw

Re: [PATCH v8 1/3] mtd: spi-nor: spansion: Add support for Read Any Register

Quoted 7 lines · On 21/02/22 04:14PM, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

The Read Any Register instruction (65h) is followed by register address and dummy cycles, then the selected register byte is returned. This patch adds a spi_mem_op template for that. The spi_mem_op is passed to spi_nor_read_reg() introduced by:
https://lore.kernel.org/linux-mtd/[email protected]/T/#m05d56c77f8d55eb6f3dee4cb138bde4ff390d6c1

Hmm, I don't think you should put patch links in the commit message. Better to put them below the "---" line.

Quoted 35 lines

---
Changes in v8:
- Remove controller_ops
- Remove spansion_read/write_any_reg()
- Add spi_mem_op macro for Read Any Register

Changes in v7:
- No change

Changes in v6:
- Add helper functions for controller_ops
- Add 'reg_addr_width' parameter to spansion_read/write_any_reg()
- Remove spi_nor_write_enable() from spansion_write_any_reg() and modified function header comment

Changes in v5:
- Fix 'if (ret == 1)' to 'if (ret < 0)' in spansion_read_any_reg()

Changes in v4:
- Fix dummy cycle calculation in spansion_read_any_reg()
- Modify comment for spansion_write_any_reg()

Changes in v3:
- Cleanup implementation

 drivers/mtd/spi-nor/spansion.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mtd/spi-nor/spansion.c +0 -0
index 9bb239f1e142..9040edf7359f 100644

drivers/mtd/spi-nor/spansion.c line 27

Quoted 8 lines
drivers/mtd/spi-nor/spansion.c +5 -0
@@ -20,6 +20,11 @@
 #define SPINOR_OP_CYPRESS_RD_FAST		0xee
 
 /* Spansion/Cypress SPI NOR flash operations. */
+#define SPI_NOR_SPANSION_RD_ANY_REG_OP(naddr, addr, ndummy, ndata, buf)	\
+	SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 0),		\
+		   SPI_MEM_OP_ADDR(naddr, addr, 0),			\
+		   SPI_MEM_OP_DUMMY(ndummy, 0),				\
+		   SPI_MEM_OP_DATA_IN(ndata, buf, 0))

With the commit message fixed,

Quoted 6 lines
drivers/mtd/spi-nor/spansion.c +0 -0
 #define SPI_NOR_SPANSION_WR_ANY_REG_OP(naddr, addr, ndata, buf)		\
 	SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 0),		\
 		   SPI_MEM_OP_ADDR(naddr, addr, 0),			\
Signature · 1 line
2.25.1
Signature · 7 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#3 lore raw

PATCH v8 2/3 mtd: spi-nor: spansion: Add support for volatile QE bit

In reply to [email protected]

From: Takahiro Kuwano <[email protected]>

Some of Infineon chips support volatile version of configuration registers and it is recommended to update volatile registers in the field application due to a risk of the non-volatile registers corruption by power interrupt.

---
Changes in v8:
- Use spi_nor_read/write_reg() functions
- Use nor->bouncebuf instead of a variable on stack

Changes in v7:
- Add missing macro definitions in v6

Changes in v6:
- Remove multi die package support

Changes in v5:
- No change

Changes in v4:
- No change

Changes in v3:
- Add multi-die package parts support

 drivers/mtd/spi-nor/spansion.c | 61 ++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
drivers/mtd/spi-nor/spansion.c +61 -0
index 9040edf7359f..5453b89a1c22 100644
@@ -10,6 +10,8 @@
 
 #define SPINOR_OP_RD_ANY_REG			0x65	/* Read any register */
 #define SPINOR_OP_WR_ANY_REG			0x71	/* Write any register */
+#define SPINOR_REG_CYPRESS_CFR1V		0x00800002
+#define SPINOR_REG_CYPRESS_CFR1V_QUAD_EN	BIT(1)	/* Quad Enable */
 #define SPINOR_REG_CYPRESS_CFR2V		0x00800003
 #define SPINOR_REG_CYPRESS_CFR2V_MEMLAT_11_24	0xb
 #define SPINOR_REG_CYPRESS_CFR3V		0x00800004
@@ -105,6 +107,65 @@ static int spi_nor_cypress_octal_dtr_dis(struct spi_nor *nor)
 	return 0;
 }
 
+/**
+ * spansion_quad_enable_volatile() - enable Quad I/O mode in volatile register.
+ * @nor:	pointer to a 'struct spi_nor'
+ * @reg_dummy:	number of dummy bytes for register read
+ *
+ * It is recommended to update volatile registers in the field application due
+ * to a risk of the non-volatile registers corruption by power interrupt. This
+ * function sets Quad Enable bit in CFR1 volatile. If users set the Quad Enable
+ * bit in the CFR1 non-volatile in advance (typically by a Flash programmer
+ * before mounting Flash on PCB), the Quad Enable bit in the CFR1 volatile is
+ * also set during Flash power-up. This function supports multi-die package
+ * parts that require to set the Quad Enable bit in each die.
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy)
+{
+	struct spi_mem_op op;
+	u32 reg_addr = SPINOR_REG_CYPRESS_CFR1V;
+	u8 cfr1v_written;
+	int ret;
+
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_RD_ANY_REG_OP(nor->addr_width, reg_addr,
+					       reg_dummy, 1, nor->bouncebuf);
+	ret = spi_nor_read_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR1V_QUAD_EN)
+		return 0;
+
+	/* Update the Quad Enable bit. */
+	nor->bouncebuf[0] |= SPINOR_REG_CYPRESS_CFR1V_QUAD_EN;
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_WR_ANY_REG_OP(nor->addr_width, reg_addr,
+					       1, nor->bouncebuf);
+	ret = spi_nor_write_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	cfr1v_written = nor->bouncebuf[0];
+
+	/* Read back and check it. */
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_RD_ANY_REG_OP(nor->addr_width, reg_addr,
+					       reg_dummy, 1, nor->bouncebuf);
+	ret = spi_nor_read_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	if (nor->bouncebuf[0] != cfr1v_written) {
+		dev_err(nor->dev, "CFR1: Read back test failed\n");
+		return -EIO;
+	}
+
+	return 0;
+}
+
 /**
  * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes.
  * @nor:		pointer to a 'struct spi_nor'
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Reviewed-by on v8 2/3
#4 lore raw

Re: [PATCH v8 2/3] mtd: spi-nor: spansion: Add support for volatile QE bit

Quoted 35 lines · On 21/02/22 04:14PM, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

Some of Infineon chips support volatile version of configuration registers and it is recommended to update volatile registers in the field application due to a risk of the non-volatile registers corruption by power interrupt.

---
Changes in v8:
- Use spi_nor_read/write_reg() functions
- Use nor->bouncebuf instead of a variable on stack

Changes in v7:
- Add missing macro definitions in v6

Changes in v6:
- Remove multi die package support

Changes in v5:
- No change

Changes in v4:
- No change

Changes in v3:
- Add multi-die package parts support

 drivers/mtd/spi-nor/spansion.c | 61 ++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
drivers/mtd/spi-nor/spansion.c +0 -0
index 9040edf7359f..5453b89a1c22 100644

drivers/mtd/spi-nor/spansion.c line 14

Quoted 5 lines
drivers/mtd/spi-nor/spansion.c +2 -0
@@ -10,6 +10,8 @@
 
 #define SPINOR_OP_RD_ANY_REG			0x65	/* Read any register */
 #define SPINOR_OP_WR_ANY_REG			0x71	/* Write any register */
+#define SPINOR_REG_CYPRESS_CFR1V		0x00800002
+#define SPINOR_REG_CYPRESS_CFR1V_QUAD_EN	BIT(1)	/* Quad Enable */

You might have to rename function and variable names based on mwalle's patches [0], depending on which series goes in first.

Other than this,

Quoted 72 lines
drivers/mtd/spi-nor/spansion.c +59 -0
 #define SPINOR_REG_CYPRESS_CFR2V		0x00800003
 #define SPINOR_REG_CYPRESS_CFR2V_MEMLAT_11_24	0xb
 #define SPINOR_REG_CYPRESS_CFR3V		0x00800004
@@ -105,6 +107,65 @@ static int spi_nor_cypress_octal_dtr_dis(struct spi_nor *nor)
 	return 0;
 }
 
+/**
+ * spansion_quad_enable_volatile() - enable Quad I/O mode in volatile register.
+ * @nor:	pointer to a 'struct spi_nor'
+ * @reg_dummy:	number of dummy bytes for register read
+ *
+ * It is recommended to update volatile registers in the field application due
+ * to a risk of the non-volatile registers corruption by power interrupt. This
+ * function sets Quad Enable bit in CFR1 volatile. If users set the Quad Enable
+ * bit in the CFR1 non-volatile in advance (typically by a Flash programmer
+ * before mounting Flash on PCB), the Quad Enable bit in the CFR1 volatile is
+ * also set during Flash power-up. This function supports multi-die package
+ * parts that require to set the Quad Enable bit in each die.
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy)
+{
+	struct spi_mem_op op;
+	u32 reg_addr = SPINOR_REG_CYPRESS_CFR1V;
+	u8 cfr1v_written;
+	int ret;
+
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_RD_ANY_REG_OP(nor->addr_width, reg_addr,
+					       reg_dummy, 1, nor->bouncebuf);
+	ret = spi_nor_read_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR1V_QUAD_EN)
+		return 0;
+
+	/* Update the Quad Enable bit. */
+	nor->bouncebuf[0] |= SPINOR_REG_CYPRESS_CFR1V_QUAD_EN;
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_WR_ANY_REG_OP(nor->addr_width, reg_addr,
+					       1, nor->bouncebuf);
+	ret = spi_nor_write_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	cfr1v_written = nor->bouncebuf[0];
+
+	/* Read back and check it. */
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_RD_ANY_REG_OP(nor->addr_width, reg_addr,
+					       reg_dummy, 1, nor->bouncebuf);
+	ret = spi_nor_read_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	if (nor->bouncebuf[0] != cfr1v_written) {
+		dev_err(nor->dev, "CFR1: Read back test failed\n");
+		return -EIO;
+	}
+
+	return 0;
+}
+
 /**
  * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes.
  * @nor:		pointer to a 'struct spi_nor'
Signature · 1 line
2.25.1

[0] https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Signature · 7 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#5 lore raw

PATCH v8 3/3 mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups

In reply to [email protected]

From: Takahiro Kuwano <[email protected]>

The S25HL-T/S25HS-T family is the Infineon SEMPER Flash with Quad SPI.

For the single-die package parts (512Mb and 1Gb), only bottom 4KB and uniform sector sizes are supported. This is due to missing or incorrect entries in SMPT. Fixup for other sector sizes configurations will be followed up as needed.

Tested on Xilinx Zynq-7000 FPGA board.

---
Changes in v8:
- Call write_disable in error case only
- Use spi_nor_read_reg() helper
- Use nor->bouncebuf instead of variable on stack
- Update ID table to use FLAGS macro

Changes in v7:
- Add missing device info table in v6

Changes in v6:
- Remove 2Gb multi die pacakge support

Changes in v5:
- Add NO_CHIP_ERASE flag to S25HL02GT and S25HS02GT

Changes in v4:
- Merge block comments about SMPT in s25hx_t_post_sfdp_fixups()
- Remove USE_CLSR flags from S25HL02GT and S25HS02GT

Changes in v3:
- Remove S25HL256T and S25HS256T
- Add S25HL02GT and S25HS02GT
- Add support for multi-die package parts support
- Remove erase_map fix for top/split sector layout
- Set ECC data unit size (16B) to writesize

 drivers/mtd/spi-nor/spansion.c | 103 +++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
drivers/mtd/spi-nor/spansion.c +103 -0
index 5453b89a1c22..4511c0cfd090 100644
@@ -166,6 +166,93 @@ static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy)
 	return 0;
 }
 
+static int s25hx_t_quad_enable(struct spi_nor *nor)
+{
+	int ret = spansion_quad_enable_volatile(nor, 0);
+
+	/* Reset WEL bit in any error cases */
+	if (ret)
+		spi_nor_write_disable(nor);
+
+	return ret;
+}
+
+static int
+s25hx_t_post_bfpt_fixups(struct spi_nor *nor,
+			 const struct sfdp_parameter_header *bfpt_header,
+			 const struct sfdp_bfpt *bfpt)
+{
+	struct spi_mem_op op;
+	int ret;
+
+	ret = spi_nor_set_4byte_addr_mode(nor, true);
+	if (ret)
+		return ret;
+	nor->addr_width = 4;
+
+	/* Replace Quad Enable with volatile version */
+	nor->params->quad_enable = s25hx_t_quad_enable;
+
+	/*
+	 * From BFPT, the page_size is set to 512B(s25hs512t) or 256B(others),
+	 * but it actually depends on the configuration register. Look up the
+	 * CFR3V and determine the page_size.
+	 */
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_RD_ANY_REG_OP(nor->addr_width,
+					       SPINOR_REG_CYPRESS_CFR3V, 0, 1,
+					       nor->bouncebuf);
+	ret = spi_nor_read_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR3V_PGSZ)
+		nor->params->page_size = 512;
+	else
+		nor->params->page_size = 256;
+
+	return 0;
+}
+
+/**
+ * s25hx_t_post_sfdp_fixups() - post SFDP fixups for S25HL-T and S25HS-T
+ * @nor:	pointer to a 'struct spi_nor'
+ *
+ * For the single-die package parts (512Mb and 1Gb), only bottom and uniform
+ * sector maps are correctly populated in the erase_map structure. This is due
+ * to missing or incorrect entries in SMPT. The table below shows all possible
+ * combinations of related register bits and its availability in SMPT. Since
+ * bottom (factorly default) and uniform are commonly used, we don't fix the
+ * erase_map for top and split.
+ *
+ *   CFR3[3] | CFR1[6] | CFR1[2] | Sector Map | Available in SMPT?
+ *  -------------------------------------------------------------------
+ *      0    |    0    |    0    | Bottom     | YES
+ *      0    |    0    |    1    | Top        | NO (decoded as Split)
+ *      0    |    1    |    0    | Split      | NO
+ *      0    |    1    |    1    | Split      | NO (decoded as Top)
+ *      1    |    0    |    0    | Uniform    | YES
+ *      1    |    0    |    1    | Uniform    | NO
+ *      1    |    1    |    0    | Uniform    | NO
+ *      1    |    1    |    1    | Uniform    | NO
+ *  -------------------------------------------------------------------
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+void s25hx_t_post_sfdp_fixups(struct spi_nor *nor)
+{
+	/* Fast Read 4B requires mode cycles but SFDP does not advertise it */
+	nor->params->reads[SNOR_CMD_READ_FAST].num_mode_clocks = 8;
+
+	/* The writesize should be ECC data unit size */
+	nor->params->writesize = 16;
+}
+
+static struct spi_nor_fixups s25hx_t_fixups = {
+	.post_bfpt = s25hx_t_post_bfpt_fixups,
+	.post_sfdp = s25hx_t_post_sfdp_fixups
+};
+
 /**
  * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes.
  * @nor:		pointer to a 'struct spi_nor'
@@ -353,6 +440,22 @@ static const struct flash_info spansion_parts[] = {
 	{ "s25fl256l",  INFO(0x016019,      0,  64 * 1024, 512)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
 		FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
+	{ "s25hl512t",  INFO6(0x342a1a, 0x0f0390, 256 * 1024, 256)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
+		.fixups = &s25hx_t_fixups },
+	{ "s25hl01gt",  INFO6(0x342a1b, 0x0f0390, 256 * 1024, 512)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
+		.fixups = &s25hx_t_fixups },
+	{ "s25hs512t",  INFO6(0x342b1a, 0x0f0390, 256 * 1024, 256)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
+		.fixups = &s25hx_t_fixups },
+	{ "s25hs01gt",  INFO6(0x342b1b, 0x0f0390, 256 * 1024, 512)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
+		.fixups = &s25hx_t_fixups },
 	{ "cy15x104q",  INFO6(0x042cc2, 0x7f7f7f, 512 * 1024, 1)
 		FLAGS(SPI_NOR_NO_ERASE) },
 	{ "s28hs512t",   INFO(0x345b1a,      0, 256 * 1024, 256)
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#6 lore raw

Re: [PATCH v8 3/3] mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups

Quoted 63 lines · On 21/02/22 04:14PM, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

The S25HL-T/S25HS-T family is the Infineon SEMPER Flash with Quad SPI.

For the single-die package parts (512Mb and 1Gb), only bottom 4KB and uniform sector sizes are supported. This is due to missing or incorrect entries in SMPT. Fixup for other sector sizes configurations will be followed up as needed.

Tested on Xilinx Zynq-7000 FPGA board.

---
Changes in v8:
- Call write_disable in error case only
- Use spi_nor_read_reg() helper
- Use nor->bouncebuf instead of variable on stack
- Update ID table to use FLAGS macro

Changes in v7:
- Add missing device info table in v6

Changes in v6:
- Remove 2Gb multi die pacakge support

Changes in v5:
- Add NO_CHIP_ERASE flag to S25HL02GT and S25HS02GT

Changes in v4:
- Merge block comments about SMPT in s25hx_t_post_sfdp_fixups()
- Remove USE_CLSR flags from S25HL02GT and S25HS02GT

Changes in v3:
- Remove S25HL256T and S25HS256T
- Add S25HL02GT and S25HS02GT
- Add support for multi-die package parts support
- Remove erase_map fix for top/split sector layout
- Set ECC data unit size (16B) to writesize

 drivers/mtd/spi-nor/spansion.c | 103 +++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
drivers/mtd/spi-nor/spansion.c +13 -0
index 5453b89a1c22..4511c0cfd090 100644
@@ -166,6 +166,93 @@ static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy)
 	return 0;
 }
 
+static int s25hx_t_quad_enable(struct spi_nor *nor)
+{
+	int ret = spansion_quad_enable_volatile(nor, 0);
+
+	/* Reset WEL bit in any error cases */
+	if (ret)
+		spi_nor_write_disable(nor);
+
+	return ret;
+}
+
+static int
+s25hx_t_post_bfpt_fixups(struct spi_nor *nor,

drivers/mtd/spi-nor/spansion.c static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy) · line 191

Quoted 10 lines
drivers/mtd/spi-nor/spansion.c +10 -0
+			 const struct sfdp_parameter_header *bfpt_header,
+			 const struct sfdp_bfpt *bfpt)
+{
+	struct spi_mem_op op;
+	int ret;
+
+	ret = spi_nor_set_4byte_addr_mode(nor, true);
+	if (ret)
+		return ret;
+	nor->addr_width = 4;

Why do you enable 4 byte address mode here? Why not set nor->params->set_4byte_addr_mode and let spi_nor_init() do it?

Quoted 11 lines
drivers/mtd/spi-nor/spansion.c +11 -0
+
+	/* Replace Quad Enable with volatile version */
+	nor->params->quad_enable = s25hx_t_quad_enable;
+
+	/*
+	 * From BFPT, the page_size is set to 512B(s25hs512t) or 256B(others),
+	 * but it actually depends on the configuration register. Look up the
+	 * CFR3V and determine the page_size.
+	 */
+	op = (struct spi_mem_op)
+		SPI_NOR_SPANSION_RD_ANY_REG_OP(nor->addr_width,

drivers/mtd/spi-nor/spansion.c static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy) · line 212

Quoted 10 lines
drivers/mtd/spi-nor/spansion.c +10 -0
+					       SPINOR_REG_CYPRESS_CFR3V, 0, 1,
+					       nor->bouncebuf);
+	ret = spi_nor_read_reg(nor, &op, SNOR_PROTO_1_1_1);
+	if (ret)
+		return ret;
+
+	if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR3V_PGSZ)
+		nor->params->page_size = 512;
+	else
+		nor->params->page_size = 256;

Ok.

Quoted 22 lines
drivers/mtd/spi-nor/spansion.c +22 -0
+
+	return 0;
+}
+
+/**
+ * s25hx_t_post_sfdp_fixups() - post SFDP fixups for S25HL-T and S25HS-T
+ * @nor:	pointer to a 'struct spi_nor'
+ *
+ * For the single-die package parts (512Mb and 1Gb), only bottom and uniform
+ * sector maps are correctly populated in the erase_map structure. This is due
+ * to missing or incorrect entries in SMPT. The table below shows all possible
+ * combinations of related register bits and its availability in SMPT. Since
+ * bottom (factorly default) and uniform are commonly used, we don't fix the
+ * erase_map for top and split.
+ *
+ *   CFR3[3] | CFR1[6] | CFR1[2] | Sector Map | Available in SMPT?
+ *  -------------------------------------------------------------------
+ *      0    |    0    |    0    | Bottom     | YES
+ *      0    |    0    |    1    | Top        | NO (decoded as Split)
+ *      0    |    1    |    0    | Split      | NO
+ *      0    |    1    |    1    | Split      | NO (decoded as Top)
+ *      1    |    0    |    0    | Uniform    | YES

drivers/mtd/spi-nor/spansion.c static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy) · line 244

Quoted 10 lines
drivers/mtd/spi-nor/spansion.c +10 -0
+ *      1    |    0    |    1    | Uniform    | NO
+ *      1    |    1    |    0    | Uniform    | NO
+ *      1    |    1    |    1    | Uniform    | NO
+ *  -------------------------------------------------------------------
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+void s25hx_t_post_sfdp_fixups(struct spi_nor *nor)
+{
+	/* Fast Read 4B requires mode cycles but SFDP does not advertise it */

SFDP does not advertise it as in SFDP table has an entry for this but the flash does not populate it correctly? Or does the SFDP table itself not supposed to have this information?

This hook should only be used for correcting SFDP information. For information that is not defined via SFDP, please use the late_init() hook.

drivers/mtd/spi-nor/spansion.c static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy) · line 248

Quoted 4 lines
drivers/mtd/spi-nor/spansion.c +4 -0
+	nor->params->reads[SNOR_CMD_READ_FAST].num_mode_clocks = 8;
+
+	/* The writesize should be ECC data unit size */
+	nor->params->writesize = 16;

Same.

Quoted 11 lines
drivers/mtd/spi-nor/spansion.c +7 -0
+}
+
+static struct spi_nor_fixups s25hx_t_fixups = {
+	.post_bfpt = s25hx_t_post_bfpt_fixups,
+	.post_sfdp = s25hx_t_post_sfdp_fixups
+};
+
 /**
  * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes.
  * @nor:		pointer to a 'struct spi_nor'

drivers/mtd/spi-nor/spansion.c static const struct flash_info spansion_parts[] = { · line 445

Quoted 6 lines
drivers/mtd/spi-nor/spansion.c +3 -0
@@ -353,6 +440,22 @@ static const struct flash_info spansion_parts[] = {
 	{ "s25fl256l",  INFO(0x016019,      0,  64 * 1024, 512)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
 		FIXUP_FLAGS(SPI_NOR_4B_OPCODES) },
+	{ "s25hl512t",  INFO6(0x342a1a, 0x0f0390, 256 * 1024, 256)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)

This is the old way of specifying flags. We changed this recently [0]. Please use just PARSE_SFDP flag, and let SFDP parser discover these capabilities. Only use flags for capabilities that can't be discovered via SFDP.

Same for other flashes.

Quoted 19 lines
drivers/mtd/spi-nor/spansion.c +13 -0
+		.fixups = &s25hx_t_fixups },
+	{ "s25hl01gt",  INFO6(0x342a1b, 0x0f0390, 256 * 1024, 512)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
+		.fixups = &s25hx_t_fixups },
+	{ "s25hs512t",  INFO6(0x342b1a, 0x0f0390, 256 * 1024, 256)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
+		.fixups = &s25hx_t_fixups },
+	{ "s25hs01gt",  INFO6(0x342b1b, 0x0f0390, 256 * 1024, 512)
+		FLAGS(USE_CLSR)
+		NO_SFDP_FLAGS(SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
+		.fixups = &s25hx_t_fixups },
 	{ "cy15x104q",  INFO6(0x042cc2, 0x7f7f7f, 512 * 1024, 1)
 		FLAGS(SPI_NOR_NO_ERASE) },
 	{ "s28hs512t",   INFO(0x345b1a,      0, 256 * 1024, 256)
Signature · 1 line
2.25.1

[0] https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Signature · 7 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#7 lore raw

Re: [PATCH v8 3/3] mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups

Quoted 69 lines · Pratyush Yadav
Quoted 68 lines · On 21/02/22 04:14PM, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

The S25HL-T/S25HS-T family is the Infineon SEMPER Flash with Quad SPI.

For the single-die package parts (512Mb and 1Gb), only bottom 4KB and uniform sector sizes are supported. This is due to missing or incorrect entries in SMPT. Fixup for other sector sizes configurations will be followed up as needed.

Tested on Xilinx Zynq-7000 FPGA board.

---
Changes in v8:
- Call write_disable in error case only
- Use spi_nor_read_reg() helper
- Use nor->bouncebuf instead of variable on stack
- Update ID table to use FLAGS macro

Changes in v7:
- Add missing device info table in v6

Changes in v6:
- Remove 2Gb multi die pacakge support

Changes in v5:
- Add NO_CHIP_ERASE flag to S25HL02GT and S25HS02GT

Changes in v4:
- Merge block comments about SMPT in s25hx_t_post_sfdp_fixups()
- Remove USE_CLSR flags from S25HL02GT and S25HS02GT

Changes in v3:
- Remove S25HL256T and S25HS256T
- Add S25HL02GT and S25HS02GT
- Add support for multi-die package parts support
- Remove erase_map fix for top/split sector layout
- Set ECC data unit size (16B) to writesize

 drivers/mtd/spi-nor/spansion.c | 103 +++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
drivers/mtd/spi-nor/spansion.c +18 -0
index 5453b89a1c22..4511c0cfd090 100644
@@ -166,6 +166,93 @@ static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy)
 	return 0;
 }
 
+static int s25hx_t_quad_enable(struct spi_nor *nor)
+{
+	int ret = spansion_quad_enable_volatile(nor, 0);
+
+	/* Reset WEL bit in any error cases */
+	if (ret)
+		spi_nor_write_disable(nor);
+
+	return ret;
+}
+
+static int
+s25hx_t_post_bfpt_fixups(struct spi_nor *nor,
+			 const struct sfdp_parameter_header *bfpt_header,
+			 const struct sfdp_bfpt *bfpt)
+{
+	struct spi_mem_op op;
+	int ret;
Quoted 9 lines

drivers/mtd/spi-nor/spansion.c static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy) · line 191

Quoted 5 lines
drivers/mtd/spi-nor/spansion.c +5 -0
+
+	ret = spi_nor_set_4byte_addr_mode(nor, true);
+	if (ret)
+		return ret;
+	nor->addr_width = 4;

Why do you enable 4 byte address mode here? Why not set nor->params->set_4byte_addr_mode and let spi_nor_init() do it?

The addr_width is used by Read Any Register op that called in SMPT parse and in this hook. I would like to sync device's addr mode and addr_width to a known state here.
nor->params->set_4byte_addr_mode is not called due to SNOR_F_4B_OPCODES flag set in spansion_late_init().

Thanks,
Takahiro

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/