1104-mtd-fsl-quadspi-Add-quad-mode-for-flash-n25q128.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. From 23cd071c47c064d56921975d196dc22177069dea Mon Sep 17 00:00:00 2001
  2. From: Yunhui Cui <yunhui.cui@nxp.com>
  3. Date: Wed, 24 Feb 2016 15:14:01 +0800
  4. Subject: [PATCH 104/113] mtd: fsl-quadspi: Add quad mode for flash n25q128
  5. Add some lut_tables to support quad mode for flash n25q128
  6. on the board ls1021a-twr and solve flash Spansion and Micron
  7. command conflict.
  8. In switch {}, The value of command SPINOR_OP_RD_EVCR and
  9. SPINOR_OP_SPANSION_RDAR is the same. They have to share
  10. the same seq_id: SEQID_RDAR_OR_RD_EVCR.
  11. Signed-off-by: Yunhui Cui <yunhui.cui@nxp.com>
  12. ---
  13. drivers/mtd/spi-nor/fsl-quadspi.c | 47 ++++++++++++++++++++++++++++---------
  14. 1 file changed, 36 insertions(+), 11 deletions(-)
  15. --- a/drivers/mtd/spi-nor/fsl-quadspi.c
  16. +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
  17. @@ -207,9 +207,9 @@
  18. #define SEQID_RDCR 9
  19. #define SEQID_EN4B 10
  20. #define SEQID_BRWR 11
  21. -#define SEQID_RDAR 12
  22. +#define SEQID_RDAR_OR_RD_EVCR 12
  23. #define SEQID_WRAR 13
  24. -
  25. +#define SEQID_WD_EVCR 14
  26. #define QUADSPI_MIN_IOMAP SZ_4M
  27. @@ -393,6 +393,7 @@ static void fsl_qspi_init_lut(struct fsl
  28. int rxfifo = q->devtype_data->rxfifo;
  29. u32 lut_base;
  30. int i;
  31. + const struct fsl_qspi_devtype_data *devtype_data = q->devtype_data;
  32. struct spi_nor *nor = &q->nor[0];
  33. u8 addrlen = (nor->addr_width == 3) ? ADDR24BIT : ADDR32BIT;
  34. @@ -489,16 +490,26 @@ static void fsl_qspi_init_lut(struct fsl
  35. qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_BRWR),
  36. base + QUADSPI_LUT(lut_base));
  37. +
  38. /*
  39. - * Read any device register.
  40. - * Used for Spansion S25FS-S family flash only.
  41. + * Flash Micron and Spansion command confilict
  42. + * use the same value 0x65. But it indicates different meaning.
  43. */
  44. - lut_base = SEQID_RDAR * 4;
  45. - qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_SPANSION_RDAR) |
  46. - LUT1(ADDR, PAD1, ADDR24BIT),
  47. - base + QUADSPI_LUT(lut_base));
  48. - qspi_writel(q, LUT0(DUMMY, PAD1, 8) | LUT1(FSL_READ, PAD1, 1),
  49. - base + QUADSPI_LUT(lut_base + 1));
  50. + lut_base = SEQID_RDAR_OR_RD_EVCR * 4;
  51. + if (devtype_data->devtype == FSL_QUADSPI_LS2080A) {
  52. + /*
  53. + * Read any device register.
  54. + * Used for Spansion S25FS-S family flash only.
  55. + */
  56. + qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_SPANSION_RDAR) |
  57. + LUT1(ADDR, PAD1, ADDR24BIT),
  58. + base + QUADSPI_LUT(lut_base));
  59. + qspi_writel(q, LUT0(DUMMY, PAD1, 8) | LUT1(FSL_READ, PAD1, 1),
  60. + base + QUADSPI_LUT(lut_base + 1));
  61. + } else {
  62. + qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_RD_EVCR),
  63. + base + QUADSPI_LUT(lut_base));
  64. + }
  65. /*
  66. * Write any device register.
  67. @@ -511,6 +522,11 @@ static void fsl_qspi_init_lut(struct fsl
  68. qspi_writel(q, LUT0(FSL_WRITE, PAD1, 1),
  69. base + QUADSPI_LUT(lut_base + 1));
  70. + /* Write EVCR register */
  71. + lut_base = SEQID_WD_EVCR * 4;
  72. + qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_WD_EVCR),
  73. + base + QUADSPI_LUT(lut_base));
  74. +
  75. fsl_qspi_lock_lut(q);
  76. }
  77. @@ -523,8 +539,15 @@ static int fsl_qspi_get_seqid(struct fsl
  78. case SPINOR_OP_READ_FAST:
  79. case SPINOR_OP_READ4_FAST:
  80. return SEQID_READ;
  81. + /*
  82. + * Spansion & Micron use the same command value 0x65
  83. + * Spansion: SPINOR_OP_SPANSION_RDAR, read any register.
  84. + * Micron: SPINOR_OP_RD_EVCR,
  85. + * read enhanced volatile configuration register.
  86. + * case SPINOR_OP_RD_EVCR:
  87. + */
  88. case SPINOR_OP_SPANSION_RDAR:
  89. - return SEQID_RDAR;
  90. + return SEQID_RDAR_OR_RD_EVCR;
  91. case SPINOR_OP_SPANSION_WRAR:
  92. return SEQID_WRAR;
  93. case SPINOR_OP_WREN:
  94. @@ -550,6 +573,8 @@ static int fsl_qspi_get_seqid(struct fsl
  95. return SEQID_EN4B;
  96. case SPINOR_OP_BRWR:
  97. return SEQID_BRWR;
  98. + case SPINOR_OP_WD_EVCR:
  99. + return SEQID_WD_EVCR;
  100. default:
  101. if (cmd == q->nor[0].erase_opcode)
  102. return SEQID_SE;