303-spi-nor-enable-4B-opcodes-for-mx25l25635f.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. --- a/drivers/mtd/spi-nor/spi-nor.c
  2. +++ b/drivers/mtd/spi-nor/spi-nor.c
  3. @@ -1025,6 +1025,7 @@ static const struct flash_info spi_nor_i
  4. { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
  5. { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
  6. { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  7. + { "mx25l25635f", INFO(0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
  8. { "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) },
  9. { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
  10. { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  11. @@ -1194,11 +1195,12 @@ static const struct flash_info spi_nor_i
  12. { },
  13. };
  14. -static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
  15. +static const struct flash_info *spi_nor_read_id(struct spi_nor *nor,
  16. + const char *name)
  17. {
  18. int tmp;
  19. u8 id[SPI_NOR_MAX_ID_LEN];
  20. - const struct flash_info *info;
  21. + const struct flash_info *info, *first_match = NULL;
  22. tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN);
  23. if (tmp < 0) {
  24. @@ -1209,10 +1211,16 @@ static const struct flash_info *spi_nor_
  25. for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
  26. info = &spi_nor_ids[tmp];
  27. if (info->id_len) {
  28. - if (!memcmp(info->id, id, info->id_len))
  29. - return &spi_nor_ids[tmp];
  30. + if (!memcmp(info->id, id, info->id_len)) {
  31. + if (!name || !strcmp(name, info->name))
  32. + return info;
  33. + if (!first_match)
  34. + first_match = info;
  35. + }
  36. }
  37. }
  38. + if (first_match)
  39. + return first_match;
  40. dev_err(nor->dev, "unrecognized JEDEC id bytes: %02x, %02x, %02x\n",
  41. id[0], id[1], id[2]);
  42. return ERR_PTR(-ENODEV);
  43. @@ -2672,7 +2680,7 @@ int spi_nor_scan(struct spi_nor *nor, co
  44. info = spi_nor_match_id(name);
  45. /* Try to auto-detect if chip name wasn't specified or not found */
  46. if (!info)
  47. - info = spi_nor_read_id(nor);
  48. + info = spi_nor_read_id(nor, NULL);
  49. if (IS_ERR_OR_NULL(info))
  50. return -ENOENT;
  51. @@ -2683,7 +2691,7 @@ int spi_nor_scan(struct spi_nor *nor, co
  52. if (name && info->id_len) {
  53. const struct flash_info *jinfo;
  54. - jinfo = spi_nor_read_id(nor);
  55. + jinfo = spi_nor_read_id(nor, name);
  56. if (IS_ERR(jinfo)) {
  57. return PTR_ERR(jinfo);
  58. } else if (jinfo != info) {