0022-mtd-spi-nor-fix-support-of-Spansion-memories.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From 4774693a681539f1e890164acc2d99fede2aa35e Mon Sep 17 00:00:00 2001
  2. From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
  3. Date: Fri, 8 Jan 2016 17:02:19 +0100
  4. Subject: [PATCH 22/33] mtd: spi-nor: fix support of Spansion memories
  5. This patch is only a transitional one. It concludes the series of patches
  6. to select op codes and protocols by manufacturer.
  7. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
  8. ---
  9. drivers/mtd/spi-nor/spi-nor.c | 53 ++++++++++++++++++++++++++++++-------------
  10. 1 file changed, 37 insertions(+), 16 deletions(-)
  11. diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
  12. index ae2cbac..8a042ab 100644
  13. --- a/drivers/mtd/spi-nor/spi-nor.c
  14. +++ b/drivers/mtd/spi-nor/spi-nor.c
  15. @@ -1458,10 +1458,35 @@ static int micron_set_single_mode(struct spi_nor *nor)
  16. return 0;
  17. }
  18. -static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info)
  19. +static int spansion_set_quad_mode(struct spi_nor *nor)
  20. {
  21. int status;
  22. + status = spansion_quad_enable(nor);
  23. + if (status) {
  24. + dev_err(nor->dev, "Spansion quad-read not enabled\n");
  25. + return -EINVAL;
  26. + }
  27. + nor->read_proto = SNOR_PROTO_1_1_4;
  28. + nor->read_opcode = SPINOR_OP_READ_1_1_4;
  29. + return 0;
  30. +}
  31. +
  32. +static int spansion_set_dual_mode(struct spi_nor *nor)
  33. +{
  34. + nor->read_proto = SNOR_PROTO_1_1_2;
  35. + nor->read_opcode = SPINOR_OP_READ_1_1_2;
  36. + return 0;
  37. +}
  38. +
  39. +static int spansion_set_single_mode(struct spi_nor *nor)
  40. +{
  41. + nor->read_proto = SNOR_PROTO_1_1_1;
  42. + return 0;
  43. +}
  44. +
  45. +static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info)
  46. +{
  47. switch (JEDEC_MFR(info)) {
  48. case SNOR_MFR_MACRONIX:
  49. return macronix_set_quad_mode(nor);
  50. @@ -1473,20 +1498,13 @@ static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info)
  51. return micron_set_quad_mode(nor);
  52. case SNOR_MFR_SPANSION:
  53. - status = spansion_quad_enable(nor);
  54. - if (status) {
  55. - dev_err(nor->dev, "Spansion quad-read not enabled\n");
  56. - return -EINVAL;
  57. - }
  58. - nor->read_proto = SNOR_PROTO_1_1_4;
  59. - break;
  60. + return spansion_set_quad_mode(nor);
  61. default:
  62. - return -EINVAL;
  63. + break;
  64. }
  65. - nor->read_opcode = SPINOR_OP_READ_1_1_4;
  66. - return 0;
  67. + return -EINVAL;
  68. }
  69. static int set_dual_mode(struct spi_nor *nor, const struct flash_info *info)
  70. @@ -1501,13 +1519,14 @@ static int set_dual_mode(struct spi_nor *nor, const struct flash_info *info)
  71. case SNOR_MFR_MICRON:
  72. return micron_set_dual_mode(nor);
  73. + case SNOR_MFR_SPANSION:
  74. + return spansion_set_dual_mode(nor);
  75. +
  76. default:
  77. - nor->read_proto = SNOR_PROTO_1_1_2;
  78. break;
  79. }
  80. - nor->read_opcode = SPINOR_OP_READ_1_1_2;
  81. - return 0;
  82. + return -EINVAL;
  83. }
  84. static int set_single_mode(struct spi_nor *nor, const struct flash_info *info)
  85. @@ -1522,12 +1541,14 @@ static int set_single_mode(struct spi_nor *nor, const struct flash_info *info)
  86. case SNOR_MFR_MICRON:
  87. return micron_set_single_mode(nor);
  88. + case SNOR_MFR_SPANSION:
  89. + return spansion_set_single_mode(nor);
  90. +
  91. default:
  92. - nor->read_proto = SNOR_PROTO_1_1_1;
  93. break;
  94. }
  95. - return 0;
  96. + return -EINVAL;
  97. }
  98. static int spi_nor_check(struct spi_nor *nor)
  99. --
  100. 2.8.1