m25p80 Quad/Dual updates
Subsystems (2)
cover m25p80 Quad/Dual updates
Hi,
This patch series allows to really use Quad and Dual SPI Read Tranfers with the m25p80 driver:
[1/4] mtd: m25p80: Enable Quad SPI read transfers for s25fl512s
[2/4] mtd: m25p80: Set rx_nbits for Quad SPI transfers
[3/4] mtd: m25p80: Add dual read support
[4/4] mtd: m25p80: Enable Dual SPI read transfers for s25fl256s1 and
s25fl512sPatch [2/4] is a bug fix.
Patches [3/4] and [4/4] may be considered of limited use (why use Dual transfers if you have Quad transfers?), but
1. not all Quad-capable devices may be connected using 6 wires,
2. it allows to test Dual SPI transfers in SPI master drivers.
This was tested with a preliminary version of the Renesas QSPI driver and a Spansion s25fl512s SPI FLASH.
Thanks for your comments!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 1/4 mtd: m25p80: Enable Quad SPI read transfers for s25fl512s
From: Geert Uytterhoeven <[email protected]>
Spansion s25fl512s supports Quad SPI transfers, hence set the M25P80_QUAD_READ flag.
--- drivers/mtd/devices/m25p80.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/devices/m25p80.c +1 -1
@@ -943,7 +943,7 @@ static const struct spi_device_id m25p_ids[] = { { "s25sl064p", INFO(0x010216, 0x4d00, 64 * 1024, 128, 0) }, { "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) }, { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512, M25P80_QUAD_READ) }, - { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, 0) }, + { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, M25P80_QUAD_READ) }, { "s70fl01gs", INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) }, { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0) }, { "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0) },
Signature · 6 lines
1.7.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 1/4] mtd: m25p80: Enable Quad SPI read transfers for s25fl512s
Quoted 15 lines · Geert Uytterhoeven
From: Geert Uytterhoeven <[email protected]>
Spansion s25fl512s supports Quad SPI transfers, hence set the
M25P80_QUAD_READflag.Signed-off-by Geert Uytterhoeven <[email protected]>--- drivers/mtd/devices/m25p80.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/devices/m25p80.c +0
-0
drivers/mtd/devices/m25p80.c static const struct spi_device_id m25p_ids[] = { · line 945
Quoted 3 lines
drivers/mtd/devices/m25p80.c +0
-0@@ -943,7 +943,7 @@ static const struct spi_device_id m25p_ids[] = { { "s25sl064p", INFO(0x010216, 0x4d00, 64 * 1024, 128, 0) }, { "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) }, { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512,
M25P80_QUAD_READ)
drivers/mtd/devices/m25p80.c static const struct spi_device_id m25p_ids[] = { · line 947
Quoted 2 lines
drivers/mtd/devices/m25p80.c +1
-0}, - { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, 0) }, + { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256,
M25P80_QUAD_READ)
drivers/mtd/devices/m25p80.c static const struct spi_device_id m25p_ids[] = { · line 949
Quoted 3 lines
drivers/mtd/devices/m25p80.c +0
-0}, { "s70fl01gs", INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) }, { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0) }, { "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0) },
Sure, the thing does support it, so why not.
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/4 mtd: m25p80: Set rx_nbits for Quad SPI transfers
In reply to Geert UytterhoevenFrom: Geert Uytterhoeven <[email protected]>
When using the Quad Read opcode, SPI masters still use Single SPI transfers, as spi_transfer.rx_nbits defaults to SPI_NBITS_SINGLE. Use SPI_NBITS_QUAD to fix this.
While an earlier version of commit 3487a63955c34ea508bcf4ca5131ddd953876e2d ("drivers: mtd: m25p80: add quad read support") did this correctly, it was forgotten in the version that got merged.
--- drivers/mtd/devices/m25p80.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/mtd/devices/m25p80.c +11 -0
@@ -489,6 +489,16 @@ static inline int m25p80_dummy_cycles_read(struct m25p *flash) } } +static inline unsigned int m25p80_rx_nbits (const struct m25p *flash) +{ +switch (flash->flash_read) { +case M25P80_QUAD : +return 4 ; +default : +return 0 ; + } +} +/* * Read an address range from the flash chip. The address range * may be any size provided it is within the physical boundaries.
@@ -519,6 +529,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,spi_message_add_tail (&t[0 ], &m); t[1 ].rx_buf = buf; + t[1 ].rx_nbits =m25p80_rx_nbits (flash); t[1 ].len = len;spi_message_add_tail (&t[1 ], &m);
Signature · 6 lines
1.7.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 2/4] mtd: m25p80: Set rx_nbits for Quad SPI transfers
Quoted 37 lines · Geert Uytterhoeven
From: Geert Uytterhoeven <[email protected]>
When using the Quad Read opcode, SPI masters still use Single SPI transfers, as spi_transfer.rx_nbits defaults to
SPI_NBITS_SINGLE. UseSPI_NBITS_QUADto fix this.While an earlier version of commit
3487a63955c34ea508bcf4ca5131ddd953876e2d("drivers: mtd: m25p80: add quad read support") did this correctly, it was forgotten in the version that got merged.Signed-off-by Geert Uytterhoeven <[email protected]>--- drivers/mtd/devices/m25p80.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/mtd/devices/m25p80.c +10
-0@@ -489,6 +489,16 @@ static inline int m25p80_dummy_cycles_read(struct m25p *flash) } } +static inline unsigned int m25p80_rx_nbits (const struct m25p *flash) +{ +switch (flash->flash_read) { +case M25P80_QUAD : +return 4 ; +default : +return 0 ; + } +} +/* * Read an address range from the flash chip. The address range * may be any size provided it is within the physical boundaries.
drivers/mtd/devices/m25p80.c static int m25p80_read(struct mtd_info *mtd, loff_t · line 534
Quoted 6 lines
drivers/mtd/devices/m25p80.c +1
-0@@ -519,6 +529,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, spi_message_add_tail(&t[0], &m); t[1 ].rx_buf = buf; + t[1 ].rx_nbits =m25p80_rx_nbits (flash); t[1 ].len = len;spi_message_add_tail (&t[1 ], &m);
Indeed.
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/4 mtd: m25p80: Add dual read support
In reply to Geert UytterhoevenFrom: Geert Uytterhoeven <[email protected]>
Add support for Dual SPI read transfers, which is supported by some Spansion SPI FLASHes.
--- drivers/mtd/devices/m25p80.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/mtd/devices/m25p80.c +19 -4
@@ -41,7 +41,8 @@#define OPCODE_WRSR 0x01/* Write status register 1 byte */ #define OPCODE_NORM_READ 0x03/* Read data bytes (low frequency) */ #define OPCODE_FAST_READ 0x0b/* Read data bytes (high frequency) */ -#define OPCODE_QUAD_READ 0x6b/* Read data bytes */ +#define OPCODE_DUAL_READ 0x3b/* Read data bytes (Dual SPI) */ +#define OPCODE_QUAD_READ 0x6b/* Read data bytes (Quad SPI) */ #define OPCODE_PP 0x02/* Page program (up to 256 bytes) */ #define OPCODE_BE_4K 0x20/* Erase 4KiB block */ #define OPCODE_BE_4K_PMC 0xd7/* Erase 4KiB block on PMC chips */
@@ -54,7 +55,8 @@/* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ #define OPCODE_NORM_READ_4B 0x13/* Read data bytes (low frequency) */ #define OPCODE_FAST_READ_4B 0x0c/* Read data bytes (high frequency) */ -#define OPCODE_QUAD_READ_4B 0x6c/* Read data bytes */ +#define OPCODE_DUAL_READ_4B 0x3c/* Read data bytes (Dual SPI) */ +#define OPCODE_QUAD_READ_4B 0x6c/* Read data bytes (Quad SPI) */ #define OPCODE_PP_4B 0x12/* Page program (up to 256 bytes) */ #define OPCODE_SE_4B 0xdc/* Sector erase (usually 64KiB) */
@@ -95,6 +97,7 @@enum read_type {M25P80_NORMAL =0 ,M25P80_FAST , +M25P80_DUAL ,M25P80_QUAD , };
@@ -479,6 +482,7 @@ static inline int m25p80_dummy_cycles_read(struct m25p *flash) {switch (flash->flash_read) {case M25P80_FAST : +case M25P80_DUAL :case M25P80_QUAD :return 1 ;case M25P80_NORMAL :
@@ -492,6 +496,8 @@ static inline int m25p80_dummy_cycles_read(struct m25p *flash)static inline unsigned int m25p80_rx_nbits (const struct m25p *flash) {switch (flash->flash_read) { +case M25P80_DUAL : +return 2 ;case M25P80_QUAD :return 4 ;default :
@@ -855,7 +861,8 @@ struct flash_info {#define SST_WRITE 0x04/* use SST byte programming */ #define M25P_NO_FR 0x08/* Can't do fastread */ #define SECT_4K_PMC 0x10/* OPCODE_BE_4K_PMC works uniformly */ -#define M25P80_QUAD_READ 0x20/* Flash supports Quad Read */ +#define M25P80_DUAL_READ 0x20/* Flash supports Dual Read */ +#define M25P80_QUAD_READ 0x40/* Flash supports Quad Read */ };#define INFO (_jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \
@@ -1226,7 +1233,7 @@ static int m25p_probe(struct spi_device *spi)if (info->flags &M25P_NO_FR ) flash->flash_read =M25P80_NORMAL ; -/* Quad-read mode takes precedence over fast/normal */ +/* Quad/Dual-read mode takes precedence over fast/normal */ if (spi->mode &SPI_RX_QUAD && info->flags &M25P80_QUAD_READ ) { ret =set_quad_mode (flash, info->jedec_id);if (ret) {
@@ -1234,6 +1241,8 @@ static int m25p_probe(struct spi_device *spi)return ret; } flash->flash_read =M25P80_QUAD ; + }else if (spi->mode &SPI_RX_DUAL && info->flags &M25P80_DUAL_READ ) { + flash->flash_read =M25P80_DUAL ; }/* Default commands */
@@ -1241,6 +1250,9 @@ static int m25p_probe(struct spi_device *spi)case M25P80_QUAD : flash->read_opcode =OPCODE_QUAD_READ ;break ; +case M25P80_DUAL : + flash->read_opcode =OPCODE_DUAL_READ ; +break ;case M25P80_FAST : flash->read_opcode =OPCODE_FAST_READ ;break ;
@@ -1265,6 +1277,9 @@ static int m25p_probe(struct spi_device *spi)case M25P80_QUAD : flash->read_opcode =OPCODE_QUAD_READ_4B ;break ; +case M25P80_DUAL : + flash->read_opcode =OPCODE_DUAL_READ_4B ; +break ;case M25P80_FAST : flash->read_opcode =OPCODE_FAST_READ_4B ;break ;
Signature · 6 lines
1.7.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 3/4] mtd: m25p80: Add dual read support
Quoted 6 lines · Geert Uytterhoeven
From: Geert Uytterhoeven <[email protected]>
Add support for Dual SPI read transfers, which is supported by some Spansion SPI FLASHes.
Signed-off-by Geert Uytterhoeven <[email protected]>
I don't see any obvious issue:
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/4 mtd: m25p80: Enable Dual SPI read transfers for s25fl256s1 and s25fl512s
In reply to Geert UytterhoevenFrom: Geert Uytterhoeven <[email protected]>
Spansion s25fl256s1 and s25fl512s support Dual SPI transfers, hence set the M25P80_DUAL_READ flag.
--- drivers/mtd/devices/m25p80.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/devices/m25p80.c +2 -2
@@ -960,8 +960,8 @@ static const struct spi_device_id m25p_ids[] = { { "s25sl032p", INFO(0x010215, 0x4d00, 64 * 1024, 64, 0) }, { "s25sl064p", INFO(0x010216, 0x4d00, 64 * 1024, 128, 0) }, { "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) }, - { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512, M25P80_QUAD_READ) }, - { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, M25P80_QUAD_READ) }, + { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512, M25P80_DUAL_READ | M25P80_QUAD_READ) }, + { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, M25P80_DUAL_READ | M25P80_QUAD_READ) }, { "s70fl01gs", INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) }, { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0) }, { "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0) },
Signature · 6 lines
1.7.9.5 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 4/4] mtd: m25p80: Enable Dual SPI read transfers for s25fl256s1 and s25fl512s
Quoted 15 lines · Geert Uytterhoeven
From: Geert Uytterhoeven <[email protected]>
Spansion s25fl256s1 and s25fl512s support Dual SPI transfers, hence set the
M25P80_DUAL_READflag.Signed-off-by Geert Uytterhoeven <[email protected]>--- drivers/mtd/devices/m25p80.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mtd/devices/m25p80.c +0
-0
drivers/mtd/devices/m25p80.c static const struct spi_device_id m25p_ids[] = { · line 963
Quoted 4 lines
drivers/mtd/devices/m25p80.c +0
-1@@ -960,8 +960,8 @@ static const struct spi_device_id m25p_ids[] = { { "s25sl032p", INFO(0x010215, 0x4d00, 64 * 1024, 64, 0) }, { "s25sl064p", INFO(0x010216, 0x4d00, 64 * 1024, 128, 0) }, { "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) }, - { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512,
M25P80_QUAD_READ)
drivers/mtd/devices/m25p80.c static const struct spi_device_id m25p_ids[] = { · line 967
Quoted 8 lines
drivers/mtd/devices/m25p80.c +0
-0}, - { "s25fl512s", INFO(0x010220, 0x4d00, 256 * 1024, 256, M25P80_QUAD_READ) }, + { "s25fl256s1", INFO(0x010219, 0x4d01, 64 * 1024, 512, M25P80_DUAL_READ | M25P80_QUAD_READ) }, + { "s25fl512s",
INFO(0x010220, 0x4d00, 256 * 1024, 256, M25P80_DUAL_READ | M25P80_QUAD_READ)}, { "s70fl01gs",INFO(0x010221, 0x4d00, 256 * 1024, 256, 0)},drivers/mtd/devices/m25p80.c +0
-0{ "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024, 64, 0) }, { "s25sl12801", INFO(0x012018, 0x0301, 64 * 1024, 256, 0) },
Why don't you lump this together with 1/4 ? :)
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] mtd: m25p80: Enable Dual SPI read transfers for s25fl256s1 and s25fl512s
Quoted 4 lines · Marek Vasut
Quoted 2 lines
Spansion s25fl256s1 and s25fl512s support Dual SPI transfers, hence set the
M25P80_DUAL_READflag.Why don't you lump this together with 1/4 ? :)
Because I don't want to delay Quad support for s25fl512s by bike-shedding about the need for Dual support.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] mtd: m25p80: Enable Dual SPI read transfers for s25fl256s1 and s25fl512s
Quoted 10 lines · Geert Uytterhoeven
Quoted 4 lines · Marek Vasut
Quoted 2 lines
Spansion s25fl256s1 and s25fl512s support Dual SPI transfers, hence set the
M25P80_DUAL_READflag.Why don't you lump this together with 1/4 ? :)
Because I don't want to delay Quad support for s25fl512s by bike-shedding about the need for Dual support.
Gr{oetje,eeting}s,
OK, gotcha. Either way is fine with me here.
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Jan 21, 2014 at 01:59:15PM +0100, Geert Uytterhoeven wrote:
Hi Brian:
should I rebase the SPI-NOR framework on this patch set?
thanks
Huang Shijie
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Huang Shijie
On Tue, Jan 21, 2014 at 01:59:15PM +0100, Geert Uytterhoeven wrote:
Hi Brian:
should I rebase the SPI-NOR framework on this patch set?
Probably, but I would wait a bit.
I will probably try to take the first two patches of Geert's patch set for 3.14, as they are a trivial improvement and a bugfix to other queued material, while the rest will likely wait. And I still don't think we've taken a close enough look at your existing series for it to be worth an additional patch submission just yet. But it's up to you.
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Geert Uytterhoeven
This patch series allows to really use Quad and Dual SPI Read Tranfers with the m25p80 driver:
[1/4] mtd: m25p80: Enable Quad SPI read transfers for s25fl512s [2/4] mtd: m25p80: Setrx_nbitsfor Quad SPI transfers
Pushed 1 and 2 to l2-mtd.git/master and will submit for 3.14-rc1, as they are trivial extensions/bugfixes for stuff we have queued now.
Quoted 3 lines
[3/4] mtd: m25p80: Add dual read support
[4/4] mtd: m25p80: Enable Dual SPI read transfers for s25fl256s1 and
s25fl512sPatches 3 and 4 are queued in l2-mtd.git/next and should go in next merge window.
Quoted 5 lines
Patch [2/4] is a bug fix.
Patches [3/4] and [4/4] may be considered of limited use (why use Dual transfers if you have Quad transfers?), but
1. not all Quad-capable devices may be connected using 6 wires,
2. it allows to test Dual SPI transfers in SPI master drivers.
Reason 1 is especially good. Thanks for the patches.
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html