mtd/spi/spi_flash: support CMD_READ_ID=0x90 case
PATCH v3 1/2 mtd/spi/spi_flash: support CMD_READ_ID=0x90 case
current code does not support spi flashes that have 0x90 read_id command, so fix this
---
Change for v3:
* split SPI flash fixes to separate patch series (series 2/3)
Change for v2:
* fix checkpatch warnings
--- drivers/mtd/spi/spi_flash.c | 66 +++++++++++++++++++++++----------- drivers/mtd/spi/spi_flash_internal.h | 1 + 2 files changed, 47 insertions(+), 20 deletions(-)
drivers/mtd/spi/spi_flash.c +46 -20
@@ -306,13 +306,44 @@ static const struct { };#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN) +struct spi_flash *spi_analize_flash_probe (struct spi_slave *spi, +u8 *idcode,size_t idcode_len,u8 *id) +{ +struct spi_flash *flash =NULL ; +int i, shift; +u8 *idp; + +#ifdef DEBUG +printf ("SF: Got idcodes\n" ); +print_buffer (0 , idcode,1 , idcode_len,0 ); +#endif + +/* count the number of continuation bytes */ +for (shift =0 , idp = idcode; + shift < idcode_len && *idp ==0x7f ; + ++shift, ++idp) +continue ; + + *id = *idp; +/* search the table for matches in shift and id */ +for (i =0 ; i <ARRAY_SIZE (flashes); ++i) +if (flashes[i].shift == shift && flashes[i].idcode == *idp) { +/* we have a match, call probe */ + flash = flashes[i].probe (spi, idp); +if (flash) +break ; + } + +return flash; +} +struct spi_flash *spi_flash_probe (unsigned int bus,unsigned int cs,unsigned int max_hz,unsigned int spi_mode) {struct spi_slave *spi;struct spi_flash *flash =NULL ; -int ret, i, shift; -u8 idcode[IDCODE_LEN ], *idp; +u8 cmd[4 ], idcode[IDCODE_LEN ], id; +int ret; spi =spi_setup_slave (bus, cs, max_hz, spi_mode);if (!spi) {
@@ -331,28 +362,23 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,if (ret) goto err_read_id; -#ifdef DEBUG -printf ("SF: Got idcodes\n" ); -print_buffer (0 , idcode,1 ,sizeof (idcode),0 ); -#endif + flash =spi_analize_flash_probe (spi, idcode,sizeof (idcode), &id); +if (id ==0xff ) { +/* try CMD_READ_ID_NEW command */ + cmd[0 ] =CMD_READ_ID_NEW ; +spi_flash_addr (0x000000 , cmd); -/* count the number of continuation bytes */ -for (shift =0 , idp = idcode; - shift <IDCODE_CONT_LEN && *idp ==0x7f ; - ++shift, ++idp) -continue ; + ret =spi_flash_cmd_read (spi, cmd,sizeof (cmd), + idcode,sizeof (idcode)); +if (ret) + goto err_read_id; -/* search the table for matches in shift and id */ -for (i =0 ; i <ARRAY_SIZE (flashes); ++i) -if (flashes[i].shift == shift && flashes[i].idcode == *idp) { -/* we have a match, call probe */ - flash = flashes[i].probe (spi, idp); -if (flash) -break ; - } + flash =spi_analize_flash_probe (spi, + idcode,sizeof (idcode), &id); + }if (!flash) { -printf ("SF: Unsupported manufacturer %02x\n" , *idp); +printf ("SF: Unsupported manufacturer %02x\n" , id); goto err_manufacturer_probe; }
drivers/mtd/spi/spi_flash_internal.h +1 -0
@@ -14,6 +14,7 @@/* Common commands */ #define CMD_READ_ID 0x9f +#define CMD_READ_ID_NEW 0x90#define CMD_READ_ARRAY_SLOW 0x03#define CMD_READ_ARRAY_FAST 0x0b
Signature · 1 line
1.7.10.4
PATCH v3 2/2 mtd/spi: add sst25l driver
Current SST driver does not support well this types of flash, so introduce a new one.
This code is a combination of sst.c driver from u-boot and sst25l.c driver from linux-3.3 release. I try to make a code as close to linux driver as it was possible.
---
Change for v3:
* split SPI flash fixes to separate patch series (series 2/3)
Change for v2:
* fix checkpatch warnings
* improve patch description
--- drivers/mtd/spi/Makefile | 3 +- drivers/mtd/spi/spi_flash.c | 3 + drivers/mtd/spi/spi_flash_internal.h | 1 + drivers/mtd/spi/sst25l.c | 372 ++++++++++++++++++++++++++++++++++ 4 files changed, 378 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/spi/sst25l.c
drivers/mtd/spi/Makefile +2 -1
@@ -34,7 +34,8 @@ COBJS-$(CONFIG_SPI_FLASH_ATMEL) += atmel.o COBJS-$(CONFIG_SPI_FLASH_EON) += eon.o COBJS-$(CONFIG_SPI_FLASH_MACRONIX) += macronix.o COBJS-$(CONFIG_SPI_FLASH_SPANSION) += spansion.o -COBJS-$(CONFIG_SPI_FLASH_SST) += sst.o +COBJS-$(CONFIG_SPI_FLASH_SST) += sst.o +COBJS-$(CONFIG_SPI_FLASH_SST25L) += sst25l.o COBJS-$(CONFIG_SPI_FLASH_STMICRO) += stmicro.o COBJS-$(CONFIG_SPI_FLASH_WINBOND) += winbond.o COBJS-$(CONFIG_SPI_FRAM_RAMTRON) += ramtron.o
drivers/mtd/spi/spi_flash.c +3 -0
@@ -285,6 +285,9 @@ static const struct { #ifdef CONFIG_SPI_FLASH_SST { 0, 0xbf, spi_flash_probe_sst, }, #endif +#ifdef CONFIG_SPI_FLASH_SST25L + { 0, 0xbf, spi_flash_probe_sst25l, }, +#endif #ifdef CONFIG_SPI_FLASH_STMICRO { 0, 0x20, spi_flash_probe_stmicro, }, #endif
drivers/mtd/spi/spi_flash_internal.h +1 -0
@@ -98,6 +98,7 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode);struct spi_flash *spi_flash_probe_eon (struct spi_slave *spi,u8 *idcode);struct spi_flash *spi_flash_probe_macronix (struct spi_slave *spi,u8 *idcode);struct spi_flash *spi_flash_probe_sst (struct spi_slave *spi,u8 *idcode); +struct spi_flash *spi_flash_probe_sst25l (struct spi_slave *spi,u8 *idcode);struct spi_flash *spi_flash_probe_stmicro (struct spi_slave *spi,u8 *idcode);struct spi_flash *spi_flash_probe_winbond (struct spi_slave *spi,u8 *idcode);struct spi_flash *spi_fram_probe_ramtron (struct spi_slave *spi,u8 *idcode);
drivers/mtd/spi/sst25l.c new file +372 -0
372 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 2/2 mtd/spi: add sst25l driver
Quoted 6 lines · On Monday 09 July 2012 14:53:21 Mikhail Kshevetskiy wrote:
Current SST driver does not support well this types of flash, so introduce a new one.
This code is a combination of
sst.cdriver from u-boot andsst25l.cdriver from linux-3.3 release. I try to make a code as close to linux driver as it was possible.
this needs rebasing & rewriting to the latest tree. a lot of cleanup/unification work has gone in (and there's more pending).
along those lines, i don't think it makes sense to write a new driver from scratch, nor use the linux one. check out my sf branch and it should be easy to merge your driver with the existing sst one.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120721/06f075f3/attachment.pgp>
PATCH v3 1/2 mtd/spi/spi_flash: support CMD_READ_ID=0x90 case
In reply to Mikhail KshevetskiyQuoted 2 lines · On Monday 09 July 2012 14:53:20 Mikhail Kshevetskiy wrote:
current code does not support spi flashes that have
0x90read_idcommand, so fix this
and what SPI flashes exactly is this ? 0x9f is the JEDEC read idcode command and is not SPI flash specific, so you're adding a lot of code that is just wasted for all existing flashes. i also suspect this might break the 0xff fallback flashes (stmicro/ramtron).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120721/56a577d0/attachment.pgp>