mtd: spi-nor: Add support for Infineon s25hl-t/s25hs-t
Subsystems (2)
v9 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://patchwork.ozlabs.org/project/linux-mtd/list/?series=287584&state=*
https://patchwork.ozlabs.org/project/linux-mtd/list/?series=288285&state=*
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 v9:
- Rebase to v5.17-rc6
- Rename function and macro per mwalle's series
- Fix some issues in ID table and fixup hook
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 | 151 +++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+)
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v9 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.
---
Change in v9:
- Rename macro per mwalle's series
- Rely on https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/
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
@@ -24,6 +24,11 @@#define SPINOR_OP_CYPRESS_RD_FAST 0xee/* Cypress SPI NOR flash operations. */ +#define CYPRESS_NOR_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 CYPRESS_NOR_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/
PATCH v9 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 v9:
- Rename function per mwalle's series
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 | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
drivers/mtd/spi-nor/spansion.c +62 -0
@@ -14,6 +14,8 @@#define SPINOR_OP_CLSR 0x30/* Clear status register 1 */ #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
@@ -106,6 +108,66 @@ static int cypress_nor_octal_dtr_dis(struct spi_nor *nor)return 0 ; } +/** +* cypress_nor_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 cypress_nor_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 ) +CYPRESS_NOR_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 ) +CYPRESS_NOR_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 ) +CYPRESS_NOR_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 ; +} +/** * cypress_nor_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/
PATCH v9 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 v9:
- Use late_init() hook to fix mode clocks and writesize
- Use PARSE_SFDP instead of NO_SFDP_FLAGS
- Use MFR_FLAGS for USE_CLSR
- Add comment block to explain about addr mode in post_bfpt_fixups()
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 | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
drivers/mtd/spi-nor/spansion.c +84 -0
@@ -168,6 +168,74 @@ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy)return 0 ; } +static int s25hx_t_quad_enable (struct spi_nor *nor) +{ +int ret =cypress_nor_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; + +/* +* From BFPT, the nor->addr_width is set to 3. In Read Any Reg op, the +* Flash takes 3-byte or 4-byte addr depending current addr mode. Since +* Read Any Reg op is called in this hook and SMPT parse, we would sync +* Flash's addr mode and nor->addr_width here. +*/ + 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 ) +CYPRESS_NOR_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 ; +} + +void s25hx_t_late_init (struct spi_nor *nor) +{ +/* Fast Read 4B requires mode cycles */ + 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, + .late_init = s25hx_t_late_init, +}; +/** * cypress_nor_octal_dtr_enable() - Enable octal DTR on Cypress flashes. * @nor: pointer to a 'struct spi_nor'
@@ -365,6 +433,22 @@ static const struct flash_info spansion_nor_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) + PARSE_SFDP + MFR_FLAGS(USE_CLSR) + .fixups = &s25hx_t_fixups }, + { "s25hl01gt", INFO6(0x342a1b, 0x0f0390, 256 * 1024, 512) + PARSE_SFDP + MFR_FLAGS(USE_CLSR) + .fixups = &s25hx_t_fixups }, + { "s25hs512t", INFO6(0x342b1a, 0x0f0390, 256 * 1024, 256) + PARSE_SFDP + MFR_FLAGS(USE_CLSR) + .fixups = &s25hx_t_fixups }, + { "s25hs01gt", INFO6(0x342b1b, 0x0f0390, 256 * 1024, 512) + PARSE_SFDP + MFR_FLAGS(USE_CLSR) + .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/