400-unlock_mx25l6406e_with_4bit_block_protect.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --- a/drivers/mtd/spi-nor/spi-nor.c
  2. +++ b/drivers/mtd/spi-nor/spi-nor.c
  3. @@ -196,7 +196,7 @@ struct flash_info {
  4. u16 page_size;
  5. u16 addr_width;
  6. - u16 flags;
  7. + u32 flags;
  8. #define SECT_4K BIT(0) /* SPINOR_OP_BE_4K works uniformly */
  9. #define SPI_NOR_NO_ERASE BIT(1) /* No erase command needed */
  10. #define SST_WRITE BIT(2) /* use SST byte programming */
  11. @@ -233,6 +233,10 @@ struct flash_info {
  12. #define SPI_NOR_SKIP_SFDP BIT(13) /* Skip parsing of SFDP tables */
  13. #define USE_CLSR BIT(14) /* use CLSR command */
  14. #define SPI_NOR_OCTAL_READ BIT(15) /* Flash supports Octal Read */
  15. +#define SPI_NOR_4BIT_BP BIT(17) /*
  16. + * Flash SR has 4 bit fields (BP0-3)
  17. + * for block protection.
  18. + */
  19. /* Part specific fixup hooks. */
  20. const struct spi_nor_fixups *fixups;
  21. @@ -1985,6 +1989,9 @@ static int spi_nor_clear_sr_bp(struct sp
  22. int ret;
  23. u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
  24. + if (nor->flags & SNOR_F_HAS_4BIT_BP)
  25. + mask |= SR_BP3;
  26. +
  27. ret = read_sr(nor);
  28. if (ret < 0) {
  29. dev_err(nor->dev, "error while reading status register\n");
  30. @@ -2338,7 +2345,7 @@ static const struct flash_info spi_nor_i
  31. { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) },
  32. { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, SECT_4K) },
  33. { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K) },
  34. - { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) },
  35. + { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_4BIT_BP) },
  36. { "mx25u2033e", INFO(0xc22532, 0, 64 * 1024, 4, SECT_4K) },
  37. { "mx25u3235f", INFO(0xc22536, 0, 64 * 1024, 64,
  38. SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  39. @@ -5026,6 +5033,9 @@ int spi_nor_scan(struct spi_nor *nor, co
  40. if (info->flags & USE_CLSR)
  41. nor->flags |= SNOR_F_USE_CLSR;
  42. + if (info->flags & SPI_NOR_4BIT_BP)
  43. + nor->flags |= SNOR_F_HAS_4BIT_BP;
  44. +
  45. if (info->flags & SPI_NOR_NO_ERASE)
  46. mtd->flags |= MTD_NO_ERASE;
  47. --- a/include/linux/mtd/spi-nor.h
  48. +++ b/include/linux/mtd/spi-nor.h
  49. @@ -127,6 +127,7 @@
  50. #define SR_BP0 BIT(2) /* Block protect 0 */
  51. #define SR_BP1 BIT(3) /* Block protect 1 */
  52. #define SR_BP2 BIT(4) /* Block protect 2 */
  53. +#define SR_BP3 BIT(5) /* Block protect 3 */
  54. #define SR_TB BIT(5) /* Top/Bottom protect */
  55. #define SR_SRWD BIT(7) /* SR write protect */
  56. /* Spansion/Cypress specific status bits */
  57. @@ -243,6 +244,7 @@ enum spi_nor_option_flags {
  58. SNOR_F_4B_OPCODES = BIT(6),
  59. SNOR_F_HAS_4BAIT = BIT(7),
  60. SNOR_F_HAS_LOCK = BIT(8),
  61. + SNOR_F_HAS_4BIT_BP = BIT(12),
  62. };
  63. /**