2
0

048-mtd-spi-nor-backport-SPI_NOR_HAS_LOCK-flag.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. From 76a4707de5e18dc32d9cb4e990686140c5664a15 Mon Sep 17 00:00:00 2001
  2. From: Brian Norris <computersforpeace@gmail.com>
  3. Date: Fri, 29 Jan 2016 11:25:35 -0800
  4. Subject: [PATCH] mtd: spi-nor: add SPI_NOR_HAS_LOCK flag
  5. We can't determine this purely by manufacturer type (see commit
  6. 67b9bcd36906 ("mtd: spi-nor: fix Spansion regressions (aliased with
  7. Winbond)")), and it's not autodetectable by anything like SFDP. So make
  8. a new flag for it.
  9. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
  10. Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
  11. Tested-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
  12. ---
  13. drivers/mtd/spi-nor/spi-nor.c | 7 +++++--
  14. 1 file changed, 5 insertions(+), 2 deletions(-)
  15. --- a/drivers/mtd/spi-nor/spi-nor.c
  16. +++ b/drivers/mtd/spi-nor/spi-nor.c
  17. @@ -68,6 +68,7 @@ struct flash_info {
  18. #define SPI_NOR_DUAL_READ 0x20 /* Flash supports Dual Read */
  19. #define SPI_NOR_QUAD_READ 0x40 /* Flash supports Quad Read */
  20. #define USE_FSR 0x80 /* use flag status register */
  21. +#define SPI_NOR_HAS_LOCK 0x100 /* Flash supports lock/unlock via SR */
  22. };
  23. #define JEDEC_MFR(info) ((info)->id[0])
  24. @@ -1156,7 +1157,8 @@ int spi_nor_scan(struct spi_nor *nor, co
  25. if (JEDEC_MFR(info) == SNOR_MFR_ATMEL ||
  26. JEDEC_MFR(info) == SNOR_MFR_INTEL ||
  27. - JEDEC_MFR(info) == SNOR_MFR_SST) {
  28. + JEDEC_MFR(info) == SNOR_MFR_SST ||
  29. + info->flags & SPI_NOR_HAS_LOCK) {
  30. write_enable(nor);
  31. write_sr(nor, 0);
  32. }
  33. @@ -1172,7 +1174,8 @@ int spi_nor_scan(struct spi_nor *nor, co
  34. mtd->_read = spi_nor_read;
  35. /* NOR protection support for STmicro/Micron chips and similar */
  36. - if (JEDEC_MFR(info) == SNOR_MFR_MICRON) {
  37. + if (JEDEC_MFR(info) == SNOR_MFR_MICRON ||
  38. + info->flags & SPI_NOR_HAS_LOCK) {
  39. nor->flash_lock = stm_lock;
  40. nor->flash_unlock = stm_unlock;
  41. nor->flash_is_locked = stm_is_locked;