405-mtd-spi-nor-detect-JEDEC-incompatible-w25q128-using-.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  2. Subject: [PATCH] mtd: spi-nor: detect JEDEC incompatible w25q128 using 0x90
  3. command
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. Some w25q128 chipsets don't support RDID (0x9f) command, they reply with
  8. 0xff-s only. To suppose such flashes fallback to the 0x90 command.
  9. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  10. ---
  11. --- a/drivers/mtd/spi-nor/spi-nor.c
  12. +++ b/drivers/mtd/spi-nor/spi-nor.c
  13. @@ -870,6 +870,18 @@ static const struct flash_info *spi_nor_
  14. }
  15. dev_err(nor->dev, "unrecognized JEDEC id bytes: %02x, %2x, %2x\n",
  16. id[0], id[1], id[2]);
  17. +
  18. + tmp = nor->read_reg(nor, 0x90, id, SPI_NOR_MAX_ID_LEN);
  19. + if (tmp < 0) {
  20. + dev_dbg(nor->dev, " error %d reading JEDEC ID\n", tmp);
  21. + return ERR_PTR(tmp);
  22. + }
  23. + dev_info(nor->dev, "using Read Manufacturer / Device ID command (0x%02x) returned %02x %02x\n",
  24. + 0x90, id[0x03], id[0x04]);
  25. + if (id[0x03] == 0xef && id[0x04] == 0x17) {
  26. + return spi_nor_match_id("w25q128");
  27. + }
  28. +
  29. return ERR_PTR(-ENODEV);
  30. }