m25p80, spi-nor: Add SFDP detect method for Macronix chips
Subsystems (2)
cover m25p80, spi-nor: Add SFDP detect method for Macronix chips
Hi linux-pm,
The serial flash discoverable parameters (SFDP) is needed to spi nor devices for some specific features. I added some sfdp structure and detect method. I have separated the chip IDs and sfdp detect method to two patches.
Patch 1 (m25p80, spi-nor: Update id list of Macronix chips) mainly updates the id table to support Macronix chips. Patch 2 includes the main sfdp functions and Macronix commands.
The code have been tested on lower version Linux and can successfully work with Macronix chips.
Thanks for review!
Jim Kuo (2):
m25p80, spi-nor: Update id list of Macronix chips
spi-nor: Add SFDP detect method
drivers/mtd/devices/m25p80.c | 83 ++++- drivers/mtd/spi-nor/Kconfig | 11 + drivers/mtd/spi-nor/spi-nor.c | 774 +++++++++++++++++++++++++++++++++++++++--- include/linux/mtd/spi-nor.h | 201 +++++++++++ 4 files changed, 1009 insertions(+), 60 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 m25p80, spi-nor: Update id list of Macronix chips
Update the Macronix chip IDs. And add two functions to m25p80.c to support some undefined read/write actions.
--- drivers/mtd/devices/m25p80.c | 83 ++++++++++++++++++++++++++++++++++++++++--- drivers/mtd/spi-nor/spi-nor.c | 44 ++++++++++++++++------- 2 files changed, 110 insertions(+), 17 deletions(-)
drivers/mtd/devices/m25p80.c +79 -4
@@ -170,6 +170,74 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)return 0 ; } +static int m25p80_write_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{ +struct m25p *flash = nor->priv; +struct spi_device *spi = flash->spi; +struct spi_transfer t[2 ] = {}; +struct spi_message m; +unsigned int dummy = cfg->dummy_cycles; +int ret; + + dummy /=8 ; + +if (cfg->wren) { + ret = nor->write_reg (nor,SPINOR_OP_WREN ,NULL ,0 ,0 ); +if (ret) +return ret; + } + +spi_message_init (&m); + + flash->command[0 ] = cfg->cmd; +m25p_addr2cmd (nor, cfg->addr, flash->command); + + t[0 ].tx_buf = flash->command; + t[0 ].len = cfg->cmd_pins + cfg->addr_pins + dummy; +spi_message_add_tail (&t[0 ], &m); + + t[1 ].tx_buf = buf; + t[1 ].tx_nbits = cfg->mode_pins; + t[1 ].len = len; +spi_message_add_tail (&t[1 ], &m); + +spi_sync (spi, &m); + +return 0 ; +} + +static int m25p80_read_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{ +struct m25p *flash = nor->priv; +struct spi_device *spi = flash->spi; +struct spi_transfer t[2 ]; +struct spi_message m; +unsigned int dummy = cfg->dummy_cycles; + + dummy /=8 ; + +spi_message_init (&m); +memset (t,0 ,sizeof (t)); + + flash->command[0 ] = cfg->cmd; +m25p_addr2cmd (nor, cfg->addr, flash->command); + + t[0 ].tx_buf = flash->command; + t[0 ].len = cfg->cmd_pins + cfg->addr_pins + dummy; +spi_message_add_tail (&t[0 ], &m); + + t[1 ].rx_buf = buf; + t[1 ].rx_nbits = cfg->mode_pins; + t[1 ].len = len; +spi_message_add_tail (&t[1 ], &m); + +spi_sync (spi, &m); + +return 0 ; +} +/* * board specific setup should have ensured the SPI clock used here * matches what the READ command supports, at least until this driver
@@ -199,6 +267,8 @@ static int m25p_probe(struct spi_device *spi) nor->erase = m25p80_erase; nor->write_reg = m25p80_write_reg; nor->read_reg = m25p80_read_reg; + nor->write_xfer = m25p80_write_xfer; + nor->read_xfer = m25p80_read_xfer; nor->dev = &spi->dev; nor->mtd = &flash->mtd;
@@ -261,10 +331,15 @@ static const struct spi_device_id m25p_ids[] = { {"mr25h256"}, {"mr25h10"}, {"gd25q32"}, {"gd25q64"}, {"160s33b"}, {"320s33b"}, {"640s33b"}, - {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"}, - {"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"}, - {"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"}, - {"mx66l1g55g"}, + {"mx25l512e"}, {"mx25l5121e"}, {"mx25l1006e"}, {"mx25l1021e"}, + {"mx25l2006e"}, {"mx25l4006e"}, {"mx25u4035"}, {"mx25v4035"}, + {"mx25l8006e"}, {"mx25u8035"}, {"mx25v8035"}, {"mx25l1606e"}, + {"mx25l1633e"}, {"mx25l1635e"}, {"mx25u1635e"}, {"mx25l3206e"}, + {"mx25l3239e"}, {"mx25l3225d"}, {"mx25l3255e"}, {"mx25l6406e"}, + {"mx25l6439e"}, {"mx25l12839f"}, {"mx25l12855e"}, + {"mx25u12835f"}, {"mx25l25635e"}, {"mx25l25655e"}, + {"mx25u25635f"}, {"mx66l51235f"}, {"mx66u51235f"}, + {"mx66l1g45g"}, {"mx66l1g55g"}, {"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"}, {"n25q512a"}, {"n25q512ax3"}, {"n25q00"}, {"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},
drivers/mtd/spi-nor/spi-nor.c +31 -13
50 lines not on this page · raw message
Signature · 1 line
1.9.1
Brian Norris
NAKRe: [PATCH 1/2] m25p80, spi-nor: Update id list of Macronix chips
Quoted 75 lines · Jim Kuo
Update the Macronix chip IDs. And add two functions to
m25p80.cto support some undefined read/write actions.Signed-off-by Jim Kuo <[email protected]>--- drivers/mtd/devices/m25p80.c | 83 ++++++++++++++++++++++++++++++++++++++++--- drivers/mtd/spi-nor/spi-nor.c | 44 ++++++++++++++++------- 2 files changed, 110 insertions(+), 17 deletions(-)drivers/mtd/devices/m25p80.c +58
-0@@ -170,6 +170,74 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)return 0 ; } +static int m25p80_write_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{ +struct m25p *flash = nor->priv; +struct spi_device *spi = flash->spi; +struct spi_transfer t[2 ] = {}; +struct spi_message m; +unsigned int dummy = cfg->dummy_cycles; +int ret; + + dummy /=8 ; + +if (cfg->wren) { + ret = nor->write_reg (nor,SPINOR_OP_WREN ,NULL ,0 ,0 ); +if (ret) +return ret; + } + +spi_message_init (&m); + + flash->command[0 ] = cfg->cmd; +m25p_addr2cmd (nor, cfg->addr, flash->command); + + t[0 ].tx_buf = flash->command; + t[0 ].len = cfg->cmd_pins + cfg->addr_pins + dummy; +spi_message_add_tail (&t[0 ], &m); + + t[1 ].tx_buf = buf; + t[1 ].tx_nbits = cfg->mode_pins; + t[1 ].len = len; +spi_message_add_tail (&t[1 ], &m); + +spi_sync (spi, &m); + +return 0 ; +} + +static int m25p80_read_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{ +struct m25p *flash = nor->priv; +struct spi_device *spi = flash->spi; +struct spi_transfer t[2 ]; +struct spi_message m; +unsigned int dummy = cfg->dummy_cycles; + + dummy /=8 ; + +spi_message_init (&m); +memset (t,0 ,sizeof (t)); + + flash->command[0 ] = cfg->cmd; +m25p_addr2cmd (nor, cfg->addr, flash->command); + + t[0 ].tx_buf = flash->command; + t[0 ].len = cfg->cmd_pins + cfg->addr_pins + dummy; +spi_message_add_tail (&t[0 ], &m); +
drivers/mtd/devices/m25p80.c static int m25p80_erase(struct spi_nor *nor, loff_t offset) · line 240
Quoted 10 lines
drivers/mtd/devices/m25p80.c +10
-0+ t[1 ].rx_buf = buf; + t[1 ].rx_nbits = cfg->mode_pins; + t[1 ].len = len; +spi_message_add_tail (&t[1 ], &m); + +spi_sync (spi, &m); + +return 0 ; +} +
All of the above is pointless. The write_xfer/read_xfer functions are not even used. (They should probably just be dropped, since they're doing nothing as-is.)
Quoted 37 lines
drivers/mtd/devices/m25p80.c +11
-4/* * board specific setup should have ensured the SPI clock used here * matches what the READ command supports, at least until this driver @@ -199,6 +267,8 @@ static int m25p_probe(struct spi_device *spi) nor->erase = m25p80_erase; nor->write_reg = m25p80_write_reg; nor->read_reg = m25p80_read_reg; + nor->write_xfer = m25p80_write_xfer; + nor->read_xfer = m25p80_read_xfer; nor->dev = &spi->dev; nor->mtd = &flash->mtd;@@ -261,10 +331,15 @@ static const struct spi_device_id m25p_ids[] = { {"mr25h256"}, {"mr25h10"}, {"gd25q32"}, {"gd25q64"}, {"160s33b"}, {"320s33b"}, {"640s33b"}, - {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"}, - {"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"}, - {"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"}, - {"mx66l1g55g"}, + {"mx25l512e"}, {"mx25l5121e"}, {"mx25l1006e"}, {"mx25l1021e"}, + {"mx25l2006e"}, {"mx25l4006e"}, {"mx25u4035"}, {"mx25v4035"}, + {"mx25l8006e"}, {"mx25u8035"}, {"mx25v8035"}, {"mx25l1606e"}, + {"mx25l1633e"}, {"mx25l1635e"}, {"mx25u1635e"}, {"mx25l3206e"}, + {"mx25l3239e"}, {"mx25l3225d"}, {"mx25l3255e"}, {"mx25l6406e"}, + {"mx25l6439e"}, {"mx25l12839f"}, {"mx25l12855e"}, + {"mx25u12835f"}, {"mx25l25635e"}, {"mx25l25655e"}, + {"mx25u25635f"}, {"mx66l51235f"}, {"mx66u51235f"}, + {"mx66l1g45g"}, {"mx66l1g55g"}, {"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"}, {"n25q512a"}, {"n25q512ax3"}, {"n25q00"}, {"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},drivers/mtd/spi-nor/spi-nor.c +0
-0
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 548
Quoted 4 lines
drivers/mtd/spi-nor/spi-nor.c +0
-1@@ -545,19 +545,37 @@ static const struct spi_device_id spi_nor_ids[] = { { "640s33b", INFO(0x898913, 0, 64 * 1024, 128, 0) },/* Macronix */ - { "mx25l2005a", INFO(0xc22012, 0, 64 * 1024, 4, SECT_4K) },
Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 549
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) },
Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 550
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) },
Nak.
(you get the picture)
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 560
Quoted 10 lines
drivers/mtd/spi-nor/spi-nor.c +0
-10- { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) }, - { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, 0) }, - { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K) }, - { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, - { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) }, - { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, - { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) }, - { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) }, - { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) }, - { "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },
This is a load of junk. You can't just remove table entries that already have a name entry. It's not my fault that flash vendors continuously output new flash generations that reuse IDs from the previous. We need name stability, for anyone who might be using these name strings to bind to the m25p80 driver.
Quoted 21 lines
drivers/mtd/spi-nor/spi-nor.c +21
-0+ { "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1, SECT_4K) }, + { "mx25l5121e", INFO(0xc22210, 0, 64 * 1024, 1, SECT_4K) }, + { "mx25l1006e", INFO(0xc22011, 0, 64 * 1024, 2, SECT_4K) }, + { "mx25l1021e", INFO(0xc22211, 0, 64 * 1024, 2, SECT_4K) }, + { "mx25l2006e", INFO(0xc22012, 0, 64 * 1024, 4, SECT_4K) }, + { "mx25l4006e", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) }, + { "mx25u4035", INFO(0xc22533, 0, 64 * 1024, 8, SECT_4K) }, + { "mx25v4035", INFO(0xc22553, 0, 64 * 1024, 8, SECT_4K) }, + { "mx25l8006e", INFO(0xc22014, 0, 64 * 1024, 16, 0) }, + { "mx25u8035", INFO(0xc22534, 0, 64 * 1024, 16, 0) }, + { "mx25v8035", INFO(0xc22554, 0, 64 * 1024, 16, 0) }, + { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) }, + { "mx25l1633e", INFO(0xc22415, 0, 64 * 1024, 32, 0) }, + { "mx25l1635e", INFO(0xc22515, 0, 64 * 1024, 32, 0) }, + { "mx25u1635e", INFO(0xc22535, 0, 64 * 1024, 32, 0) }, + { "mx25l3206e", INFO(0xc22016, 0, 64 * 1024, 64, 0) }, + { "mx25l3239e", INFO(0xc22536, 0, 64 * 1024, 64, SPI_NOR_QUAD_READ) }, + { "mx25l3225d", INFO(0xc25e16, 0, 64 * 1024, 64, 0) }, + { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25l6406e", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, + { "mx25l6439e", INFO(0xc22537, 0, 64 * 1024, 128, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 578
Quoted 10 lines
drivers/mtd/spi-nor/spi-nor.c +10
-0+ { "mx25l12839f", INFO(0xc22018, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) }, + { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25u12835f", INFO(0xc22538, 0, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66l51235f", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66u51235f", INFO(0xc2253a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66l1g45g", INFO(0xc2201b, 0, 64 * 1024, 2048, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
You need to do a lot better job of documenting your patches (i.e., describe why you're doing these things) if you want me to take them.
What's more, the SFDP support you're trying to add should be done in a way where you *don't* need to muck with the ID table every time. With SFDP you can get most/all this information anyway, and devices should just be able to bind to this driver using a generic name like "spi-nor,sfdp" or something like that, instead of having to expand this table.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 581
Quoted 3 lines
drivers/mtd/spi-nor/spi-nor.c +0
-0/* Micron */ { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, 0) },
Brian
Re: [PATCH 1/2] m25p80, spi-nor: Update id list of Macronix chips
Quoted 205 lines · Brian Norris
Quoted 75 lines · Jim Kuo
Update the Macronix chip IDs. And add two functions to
m25p80.cto support some undefined read/write actions.Signed-off-by Jim Kuo <[email protected]>--- drivers/mtd/devices/m25p80.c | 83 ++++++++++++++++++++++++++++++++++++++++--- drivers/mtd/spi-nor/spi-nor.c | 44 ++++++++++++++++------- 2 files changed, 110 insertions(+), 17 deletions(-)drivers/mtd/devices/m25p80.c +58
-0@@ -170,6 +170,74 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)return 0 ; } +static int m25p80_write_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{ +struct m25p *flash = nor->priv; +struct spi_device *spi = flash->spi; +struct spi_transfer t[2 ] = {}; +struct spi_message m; +unsigned int dummy = cfg->dummy_cycles; +int ret; + + dummy /=8 ; + +if (cfg->wren) { + ret = nor->write_reg (nor,SPINOR_OP_WREN ,NULL ,0 ,0 ); +if (ret) +return ret; + } + +spi_message_init (&m); + + flash->command[0 ] = cfg->cmd; +m25p_addr2cmd (nor, cfg->addr, flash->command); + + t[0 ].tx_buf = flash->command; + t[0 ].len = cfg->cmd_pins + cfg->addr_pins + dummy; +spi_message_add_tail (&t[0 ], &m); + + t[1 ].tx_buf = buf; + t[1 ].tx_nbits = cfg->mode_pins; + t[1 ].len = len; +spi_message_add_tail (&t[1 ], &m); + +spi_sync (spi, &m); + +return 0 ; +} + +static int m25p80_read_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{ +struct m25p *flash = nor->priv; +struct spi_device *spi = flash->spi; +struct spi_transfer t[2 ]; +struct spi_message m; +unsigned int dummy = cfg->dummy_cycles; + + dummy /=8 ; + +spi_message_init (&m); +memset (t,0 ,sizeof (t)); + + flash->command[0 ] = cfg->cmd; +m25p_addr2cmd (nor, cfg->addr, flash->command); + + t[0 ].tx_buf = flash->command; + t[0 ].len = cfg->cmd_pins + cfg->addr_pins + dummy; +spi_message_add_tail (&t[0 ], &m); +drivers/mtd/devices/m25p80.c static int m25p80_erase(struct spi_nor *nor, loff_t offset) · line 240
Quoted 10 lines
drivers/mtd/devices/m25p80.c +10
-0+ t[1 ].rx_buf = buf; + t[1 ].rx_nbits = cfg->mode_pins; + t[1 ].len = len; +spi_message_add_tail (&t[1 ], &m); + +spi_sync (spi, &m); + +return 0 ; +} +All of the above is pointless. The write_xfer/read_xfer functions are not even used. (They should probably just be dropped, since they're doing nothing as-is.)
Quoted 37 lines
drivers/mtd/devices/m25p80.c +11
-4/* * board specific setup should have ensured the SPI clock used here * matches what the READ command supports, at least until this driver @@ -199,6 +267,8 @@ static int m25p_probe(struct spi_device *spi) nor->erase = m25p80_erase; nor->write_reg = m25p80_write_reg; nor->read_reg = m25p80_read_reg; + nor->write_xfer = m25p80_write_xfer; + nor->read_xfer = m25p80_read_xfer; nor->dev = &spi->dev; nor->mtd = &flash->mtd;@@ -261,10 +331,15 @@ static const struct spi_device_id m25p_ids[] = { {"mr25h256"}, {"mr25h10"}, {"gd25q32"}, {"gd25q64"}, {"160s33b"}, {"320s33b"}, {"640s33b"}, - {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"}, - {"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"}, - {"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"}, - {"mx66l1g55g"}, + {"mx25l512e"}, {"mx25l5121e"}, {"mx25l1006e"}, {"mx25l1021e"}, + {"mx25l2006e"}, {"mx25l4006e"}, {"mx25u4035"}, {"mx25v4035"}, + {"mx25l8006e"}, {"mx25u8035"}, {"mx25v8035"}, {"mx25l1606e"}, + {"mx25l1633e"}, {"mx25l1635e"}, {"mx25u1635e"}, {"mx25l3206e"}, + {"mx25l3239e"}, {"mx25l3225d"}, {"mx25l3255e"}, {"mx25l6406e"}, + {"mx25l6439e"}, {"mx25l12839f"}, {"mx25l12855e"}, + {"mx25u12835f"}, {"mx25l25635e"}, {"mx25l25655e"}, + {"mx25u25635f"}, {"mx66l51235f"}, {"mx66u51235f"}, + {"mx66l1g45g"}, {"mx66l1g55g"}, {"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"}, {"n25q512a"}, {"n25q512ax3"}, {"n25q00"}, {"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},drivers/mtd/spi-nor/spi-nor.c +0
-0drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 548
Quoted 4 lines
drivers/mtd/spi-nor/spi-nor.c +0
-1@@ -545,19 +545,37 @@ static const struct spi_device_id spi_nor_ids[] = { { "640s33b", INFO(0x898913, 0, 64 * 1024, 128, 0) },/* Macronix */ - { "mx25l2005a", INFO(0xc22012, 0, 64 * 1024, 4, SECT_4K) },Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 549
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) },Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 550
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) },Nak.
(you get the picture)
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 560
Quoted 10 lines
drivers/mtd/spi-nor/spi-nor.c +0
-10- { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) }, - { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, 0) }, - { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K) }, - { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, - { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) }, - { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, - { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) }, - { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) }, - { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_QUAD_READ) }, - { "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) },This is a load of junk. You can't just remove table entries that already have a name entry. It's not my fault that flash vendors continuously output new flash generations that reuse IDs from the previous. We need name stability, for anyone who might be using these name strings to bind to the m25p80 driver.
Quoted 21 lines
drivers/mtd/spi-nor/spi-nor.c +21
-0+ { "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1, SECT_4K) }, + { "mx25l5121e", INFO(0xc22210, 0, 64 * 1024, 1, SECT_4K) }, + { "mx25l1006e", INFO(0xc22011, 0, 64 * 1024, 2, SECT_4K) }, + { "mx25l1021e", INFO(0xc22211, 0, 64 * 1024, 2, SECT_4K) }, + { "mx25l2006e", INFO(0xc22012, 0, 64 * 1024, 4, SECT_4K) }, + { "mx25l4006e", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) }, + { "mx25u4035", INFO(0xc22533, 0, 64 * 1024, 8, SECT_4K) }, + { "mx25v4035", INFO(0xc22553, 0, 64 * 1024, 8, SECT_4K) }, + { "mx25l8006e", INFO(0xc22014, 0, 64 * 1024, 16, 0) }, + { "mx25u8035", INFO(0xc22534, 0, 64 * 1024, 16, 0) }, + { "mx25v8035", INFO(0xc22554, 0, 64 * 1024, 16, 0) }, + { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) }, + { "mx25l1633e", INFO(0xc22415, 0, 64 * 1024, 32, 0) }, + { "mx25l1635e", INFO(0xc22515, 0, 64 * 1024, 32, 0) }, + { "mx25u1635e", INFO(0xc22535, 0, 64 * 1024, 32, 0) }, + { "mx25l3206e", INFO(0xc22016, 0, 64 * 1024, 64, 0) }, + { "mx25l3239e", INFO(0xc22536, 0, 64 * 1024, 64, SPI_NOR_QUAD_READ) }, + { "mx25l3225d", INFO(0xc25e16, 0, 64 * 1024, 64, 0) }, + { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25l6406e", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, + { "mx25l6439e", INFO(0xc22537, 0, 64 * 1024, 128, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 578
Quoted 10 lines
drivers/mtd/spi-nor/spi-nor.c +10
-0+ { "mx25l12839f", INFO(0xc22018, 0, 64 * 1024, 256, SPI_NOR_QUAD_READ) }, + { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25u12835f", INFO(0xc22538, 0, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66l51235f", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66u51235f", INFO(0xc2253a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66l1g45g", INFO(0xc2201b, 0, 64 * 1024, 2048, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },You need to do a lot better job of documenting your patches (i.e., describe why you're doing these things) if you want me to take them.
What's more, the SFDP support you're trying to add should be done in a way where you *don't* need to muck with the ID table every time. With SFDP you can get most/all this information anyway, and devices should just be able to bind to this driver using a generic name like "spi-nor,sfdp" or something like that, instead of having to expand this table.
Quoted 1 line
Quoted 4 lines
Quoted 2 lines
/* Micron */ { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, 0) },Brian
Hi Brian,
Thanks for your review and comments.
The write_xfer/read_xfer functions actually are used in patch 2.
- read_xfer: for macronix_block_lock function.
- write_xfer: for sfdp_read, macronix_read_lock_status function.
Original read/write fcuntions can only support one type transfer I/O (such as FAST_READ, DUAL_READ or QUAD_READ which was detected at begin), and they also only support fixed cycle of dummy (bind with transfer command). So the commands not related to data transfer, such as sfdp read, lock/unlock are hard to use original read/write. That's why I built these two of functions. I thought they are suitable for this condition.
Second, sorry that I directly delete original chip IDs. Some chips are not supported by Macronix anymore, so I change the name to a more popular one and keep the original device ID. I also add lots of new devices to the table. I forgot that the name might still be needed by someone.
And you're right, the sfdp detection is no need to read IDs. I'll remove these part of modifications in the next version. I hope this way can make my patch function more simple.
Summary for next version:
- Document the patch better and more detail.
- Remove the part of ID modifications.
Please let me know if there are any other suggestions.
Thanks again!
Jim Kuo
Re: [PATCH 1/2] m25p80, spi-nor: Update id list of Macronix chips
(fixed Huang's current email)
Hi,
Quoted 12 lines · Jim-Ting Kuo
Quoted 10 lines · Brian Norris
Quoted 9 lines · Jim Kuo
drivers/mtd/devices/m25p80.c +3
-0@@ -170,6 +170,74 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)return 0 ; } +static int m25p80_write_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{
...
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/mtd/devices/m25p80.c +5
-0+} + +static int m25p80_read_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{
...
Quoted 61 lines
Quoted 61 lines
drivers/mtd/devices/m25p80.c
Quoted 2 lines
drivers/mtd/devices/m25p80.c +2
-0+} +All of the above is pointless. The write_xfer/read_xfer functions are not even used. (They should probably just be dropped, since they're doing nothing as-is.)
Quoted 37 lines
/*
* board specific setup should have ensured the SPI clock used here
* matches what the READ command supports, at least until this driverdrivers/mtd/devices/m25p80.c +11
-4@@ -199,6 +267,8 @@ static int m25p_probe(struct spi_device *spi) nor->erase = m25p80_erase; nor->write_reg = m25p80_write_reg; nor->read_reg = m25p80_read_reg; + nor->write_xfer = m25p80_write_xfer; + nor->read_xfer = m25p80_read_xfer; nor->dev = &spi->dev; nor->mtd = &flash->mtd;@@ -261,10 +331,15 @@ static const struct spi_device_id m25p_ids[] = { {"mr25h256"}, {"mr25h10"}, {"gd25q32"}, {"gd25q64"}, {"160s33b"}, {"320s33b"}, {"640s33b"}, - {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"}, - {"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"}, - {"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"}, - {"mx66l1g55g"}, + {"mx25l512e"}, {"mx25l5121e"}, {"mx25l1006e"}, {"mx25l1021e"}, + {"mx25l2006e"}, {"mx25l4006e"}, {"mx25u4035"}, {"mx25v4035"}, + {"mx25l8006e"}, {"mx25u8035"}, {"mx25v8035"}, {"mx25l1606e"}, + {"mx25l1633e"}, {"mx25l1635e"}, {"mx25u1635e"}, {"mx25l3206e"}, + {"mx25l3239e"}, {"mx25l3225d"}, {"mx25l3255e"}, {"mx25l6406e"}, + {"mx25l6439e"}, {"mx25l12839f"}, {"mx25l12855e"}, + {"mx25u12835f"}, {"mx25l25635e"}, {"mx25l25655e"}, + {"mx25u25635f"}, {"mx66l51235f"}, {"mx66u51235f"}, + {"mx66l1g45g"}, {"mx66l1g55g"}, {"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"}, {"n25q512a"}, {"n25q512ax3"}, {"n25q00"}, {"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},drivers/mtd/spi-nor/spi-nor.c +0
-0drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 548
Quoted 4 lines
drivers/mtd/spi-nor/spi-nor.c +0
-1@@ -545,19 +545,37 @@ static const struct spi_device_id spi_nor_ids[] = { { "640s33b", INFO(0x898913, 0, 64 * 1024, 128, 0) },/* Macronix */ - { "mx25l2005a", INFO(0xc22012, 0, 64 * 1024, 4, SECT_4K) },Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 549
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) },Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 550
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) },Nak.
(you get the picture)
[...]
Quoted 11 lines
Quoted 10 lines
You need to do a lot better job of documenting your patches (i.e., describe why you're doing these things) if you want me to take them.
What's more, the SFDP support you're trying to add should be done in a way where you *don't* need to muck with the ID table every time. With SFDP you can get most/all this information anyway, and devices should just be able to bind to this driver using a generic name like "spi-nor,sfdp" or something like that, instead of having to expand this table.
Quoted 9 lines
The write_xfer/read_xfer functions actually are used in patch 2.
-read_xfer: formacronix_block_lockfunction.
-write_xfer: forsfdp_read,macronix_read_lock_statusfunction.
Original read/write fcuntions can only support one type transfer I/O (such asFAST_READ,DUAL_READorQUAD_READwhich was detected at begin), and they also only support fixed cycle of dummy (bind with transfer command). So the commands not related to data transfer, such as sfdp read, lock/unlock are hard to use original read/write. That's why I built these two of functions. I thought they are suitable for this condition.
OK, I suppose that's a little more reasonable. But I want to make sure this is actually necessary. I suppose we can't get this functionality with the existing read_reg()/write_reg() ops, can we?
I'm not actually sure the exact purpose of the read_xfer()/write_xfer() functions as originally defined. They obviously weren't used yet. Perhaps Huang can comment here?
But this also suggests that you really need to split your patches more. You're doing many unrelated things in each patch, and you provide no rationale for much of it.
Quoted 10 lines
Second, sorry that I directly delete original chip IDs. Some chips are not supported by Macronix anymore, so I change the name to a more popular one and keep the original device ID. I also add lots of new devices to the table. I forgot that the name might still be needed by someone.
And you're right, the sfdp detection is no need to read IDs. I'll remove these part of modifications in the next version. I hope this way can make my patch function more simple.Summary for next version:
- Document the patch better and more detail.
Definitely.
Quoted 1 line
- Remove the part of ID modifications.
Yes. Or at least, don't remove/rename old entries. If new flash with names are compatible with old names, just use the old name.
If you need to add any information to existing entries, note why. And if you need to add new entries, make these a separate patch.
Quoted 1 line
Please let me know if there are any other suggestions.
Big goal: make your patches smaller, so that they encapsulate only a single thought and can be easily described by you and understood/reviewed by others.
You might also strip down your patches to just what's necessary to detect a flash using only SFDP (not binding to a particular name/ID in the spi_nor_ids[] table). Worrying about the OTP, lock/unlock, etc., that you loaded into patch 2 will more likely bog down your review. Or at least, make these changes into an atomic patch (or patch set) that's at the end of the series, so we can tackle the more important chunks first.
Brian
Re: [PATCH 1/2] m25p80, spi-nor: Update id list of Macronix chips
Quoted 107 lines · Brian Norris
(fixed Huang's current email)
Hi,
Quoted 12 lines · Jim-Ting Kuo
Quoted 10 lines · Brian Norris
Quoted 9 lines · Jim Kuo
drivers/mtd/devices/m25p80.c +3
-0@@ -170,6 +170,74 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)return 0 ; } +static int m25p80_write_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{...
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/mtd/devices/m25p80.c +5
-0+} + +static int m25p80_read_xfer (struct spi_nor *nor, +struct spi_nor_xfer_cfg *cfg,u8 *buf,size_t len) +{...
Quoted 61 lines
Quoted 61 lines
drivers/mtd/devices/m25p80.c
Quoted 2 lines
drivers/mtd/devices/m25p80.c +2
-0+} +All of the above is pointless. The write_xfer/read_xfer functions are not even used. (They should probably just be dropped, since they're doing nothing as-is.)
Quoted 37 lines
/*
* board specific setup should have ensured the SPI clock used here
* matches what the READ command supports, at least until this driverdrivers/mtd/devices/m25p80.c +11
-4@@ -199,6 +267,8 @@ static int m25p_probe(struct spi_device *spi) nor->erase = m25p80_erase; nor->write_reg = m25p80_write_reg; nor->read_reg = m25p80_read_reg; + nor->write_xfer = m25p80_write_xfer; + nor->read_xfer = m25p80_read_xfer; nor->dev = &spi->dev; nor->mtd = &flash->mtd;@@ -261,10 +331,15 @@ static const struct spi_device_id m25p_ids[] = { {"mr25h256"}, {"mr25h10"}, {"gd25q32"}, {"gd25q64"}, {"160s33b"}, {"320s33b"}, {"640s33b"}, - {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"}, - {"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"}, - {"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"}, - {"mx66l1g55g"}, + {"mx25l512e"}, {"mx25l5121e"}, {"mx25l1006e"}, {"mx25l1021e"}, + {"mx25l2006e"}, {"mx25l4006e"}, {"mx25u4035"}, {"mx25v4035"}, + {"mx25l8006e"}, {"mx25u8035"}, {"mx25v8035"}, {"mx25l1606e"}, + {"mx25l1633e"}, {"mx25l1635e"}, {"mx25u1635e"}, {"mx25l3206e"}, + {"mx25l3239e"}, {"mx25l3225d"}, {"mx25l3255e"}, {"mx25l6406e"}, + {"mx25l6439e"}, {"mx25l12839f"}, {"mx25l12855e"}, + {"mx25u12835f"}, {"mx25l25635e"}, {"mx25l25655e"}, + {"mx25u25635f"}, {"mx66l51235f"}, {"mx66u51235f"}, + {"mx66l1g45g"}, {"mx66l1g55g"}, {"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"}, {"n25q512a"}, {"n25q512ax3"}, {"n25q00"}, {"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},drivers/mtd/spi-nor/spi-nor.c +0
-0drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 548
Quoted 4 lines
drivers/mtd/spi-nor/spi-nor.c +0
-1@@ -545,19 +545,37 @@ static const struct spi_device_id spi_nor_ids[] = { { "640s33b", INFO(0x898913, 0, 64 * 1024, 128, 0) },/* Macronix */ - { "mx25l2005a", INFO(0xc22012, 0, 64 * 1024, 4, SECT_4K) },Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 549
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) },Nak.
drivers/mtd/spi-nor/spi-nor.c static const struct spi_device_id spi_nor_ids[] = { · line 550
Quoted 1 line
drivers/mtd/spi-nor/spi-nor.c +0
-1- { "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) },Nak.
(you get the picture)
[...]
Quoted 11 lines
Quoted 10 lines
You need to do a lot better job of documenting your patches (i.e., describe why you're doing these things) if you want me to take them.
What's more, the SFDP support you're trying to add should be done in a way where you *don't* need to muck with the ID table every time. With SFDP you can get most/all this information anyway, and devices should just be able to bind to this driver using a generic name like "spi-nor,sfdp" or something like that, instead of having to expand this table.
Quoted 9 lines
The write_xfer/read_xfer functions actually are used in patch 2.
-read_xfer: formacronix_block_lockfunction.
-write_xfer: forsfdp_read,macronix_read_lock_statusfunction.
Original read/write fcuntions can only support one type transfer I/O (such asFAST_READ,DUAL_READorQUAD_READwhich was detected at begin), and they also only support fixed cycle of dummy (bind with transfer command). So the commands not related to data transfer, such as sfdp read, lock/unlock are hard to use original read/write. That's why I built these two of functions. I thought they are suitable for this condition.
Quoted 7 lines
OK, I suppose that's a little more reasonable. But I want to make sure this is actually necessary. I suppose we can't get this functionality with the existing read_reg()/write_reg() ops, can we?
I'm not actually sure the exact purpose of the read_xfer()/write_xfer() functions as originally defined. They obviously weren't used yet. Perhaps Huang can comment here?
The read_xfer()/write_xfer() are designed for the strange spi-nor controllers which has special optimizations for some operations, such as combine several operations into one operation.
I am not familiar with SFDP, but I think it will be okay if the SFDP implements the read_xfer()/write_xfer() if it really can not be implemented by the read/write/read_reg/write_reg.
please see:
http://lists.infradead.org/pipermail/linux-mtd/2013-November/050492.html
Please split these patch into small patches, and document it well. :)
thanks
Huang Shijie
PATCH 2/2 spi-nor: Add SFDP detect method
In reply to Jim KuoThe following are the details of patch:
- Add read/write scurity register functions to support some commands.
- Add suspend/resume commands.
- Add sfdp option to Kconfig and *_detect_sfdp function to support some specific commands. I also rearranged the setting steps in func spi_nor_scan to fit the sfdp method.
- The sfdp related functions have tested with Macronix chips, so I also add some commands for Macronix. Such as protection region (security OTP) and three types of islocked/lock/unlcok functions.
- Add some definitions and data structures to spi-nor.h to support above modifications.
Thanks!
--- drivers/mtd/spi-nor/Kconfig | 11 + drivers/mtd/spi-nor/spi-nor.c | 730 +++++++++++++++++++++++++++++++++++++++--- include/linux/mtd/spi-nor.h | 201 ++++++++++++ 3 files changed, 899 insertions(+), 43 deletions(-)
drivers/mtd/spi-nor/Kconfig +11 -0
@@ -21,6 +21,17 @@ config MTD_SPI_NOR_USE_4K_SECTORS Please note that some tools/drivers/filesystems may not work with 4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum). +config MTD_SPI_NOR_SFDP + bool "Serial Flash Discoverable Parameters (SFDP) Probe" + default n + help + SFDP includes the most detailed information of SPI NOR flash memory. + It can be used to detect flash and get devices' parameters. + + Attention that there are many flash flags can not covered by SFDP such + as SST_WRITE, USE_FSR, SPI_NOR_NO_FR and SECT_4K_PMC. Please do not + enable this option if your device is highly related with these flags. + config SPI_FSL_QUADSPI tristate "Freescale Quad SPI controller" depends on ARCH_MXC
drivers/mtd/spi-nor/spi-nor.c +687 -43
819 lines not on this page · raw message
include/linux/mtd/spi-nor.h +201 -0
219 lines not on this page · raw message
Signature · 1 line
1.9.1