1101-mtd-spi-nor-fsl-quadspi-extend-support-for-some-spec.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. From acfc6e9b34b3b3ca0d8bbe366dd08b0fac21c740 Mon Sep 17 00:00:00 2001
  2. From: Yunhui Cui <yunhui.cui@nxp.com>
  3. Date: Tue, 2 Feb 2016 12:21:12 +0800
  4. Subject: [PATCH 101/113] mtd: spi-nor: fsl-quadspi: extend support for some
  5. special requerment.
  6. Add extra info in LUT table to support some special requerments.
  7. Spansion S25FS-S family flash need some special operations.
  8. Signed-off-by: Yunhui Cui <yunhui.cui@nxp.com>
  9. ---
  10. drivers/mtd/spi-nor/fsl-quadspi.c | 44 +++++++++++++++++++++++++++++++++++--
  11. include/linux/mtd/spi-nor.h | 4 ++++
  12. 2 files changed, 46 insertions(+), 2 deletions(-)
  13. --- a/drivers/mtd/spi-nor/fsl-quadspi.c
  14. +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
  15. @@ -205,6 +205,9 @@
  16. #define SEQID_RDCR 9
  17. #define SEQID_EN4B 10
  18. #define SEQID_BRWR 11
  19. +#define SEQID_RDAR 12
  20. +#define SEQID_WRAR 13
  21. +
  22. #define QUADSPI_MIN_IOMAP SZ_4M
  23. @@ -470,6 +473,28 @@ static void fsl_qspi_init_lut(struct fsl
  24. qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_BRWR),
  25. base + QUADSPI_LUT(lut_base));
  26. + /*
  27. + * Read any device register.
  28. + * Used for Spansion S25FS-S family flash only.
  29. + */
  30. + lut_base = SEQID_RDAR * 4;
  31. + qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_SPANSION_RDAR) |
  32. + LUT1(ADDR, PAD1, ADDR24BIT),
  33. + base + QUADSPI_LUT(lut_base));
  34. + qspi_writel(q, LUT0(DUMMY, PAD1, 8) | LUT1(FSL_READ, PAD1, 1),
  35. + base + QUADSPI_LUT(lut_base + 1));
  36. +
  37. + /*
  38. + * Write any device register.
  39. + * Used for Spansion S25FS-S family flash only.
  40. + */
  41. + lut_base = SEQID_WRAR * 4;
  42. + qspi_writel(q, LUT0(CMD, PAD1, SPINOR_OP_SPANSION_WRAR) |
  43. + LUT1(ADDR, PAD1, ADDR24BIT),
  44. + base + QUADSPI_LUT(lut_base));
  45. + qspi_writel(q, LUT0(FSL_WRITE, PAD1, 1),
  46. + base + QUADSPI_LUT(lut_base + 1));
  47. +
  48. fsl_qspi_lock_lut(q);
  49. }
  50. @@ -477,9 +502,15 @@ static void fsl_qspi_init_lut(struct fsl
  51. static int fsl_qspi_get_seqid(struct fsl_qspi *q, u8 cmd)
  52. {
  53. switch (cmd) {
  54. + case SPINOR_OP_READ4_1_1_4:
  55. case SPINOR_OP_READ_1_1_4:
  56. case SPINOR_OP_READ_FAST:
  57. + case SPINOR_OP_READ4_FAST:
  58. return SEQID_READ;
  59. + case SPINOR_OP_SPANSION_RDAR:
  60. + return SEQID_RDAR;
  61. + case SPINOR_OP_SPANSION_WRAR:
  62. + return SEQID_WRAR;
  63. case SPINOR_OP_WREN:
  64. return SEQID_WREN;
  65. case SPINOR_OP_WRDI:
  66. @@ -491,6 +522,7 @@ static int fsl_qspi_get_seqid(struct fsl
  67. case SPINOR_OP_CHIP_ERASE:
  68. return SEQID_CHIP_ERASE;
  69. case SPINOR_OP_PP:
  70. + case SPINOR_OP_PP_4B:
  71. return SEQID_PP;
  72. case SPINOR_OP_RDID:
  73. return SEQID_RDID;
  74. @@ -830,8 +862,12 @@ static int fsl_qspi_read_reg(struct spi_
  75. {
  76. int ret;
  77. struct fsl_qspi *q = nor->priv;
  78. + u32 to = 0;
  79. +
  80. + if (opcode == SPINOR_OP_SPANSION_RDAR)
  81. + memcpy(&to, nor->cmd_buf, 4);
  82. - ret = fsl_qspi_runcmd(q, opcode, 0, len);
  83. + ret = fsl_qspi_runcmd(q, opcode, to, len);
  84. if (ret)
  85. return ret;
  86. @@ -843,9 +879,13 @@ static int fsl_qspi_write_reg(struct spi
  87. {
  88. struct fsl_qspi *q = nor->priv;
  89. int ret;
  90. + u32 to = 0;
  91. +
  92. + if (opcode == SPINOR_OP_SPANSION_WRAR)
  93. + memcpy(&to, nor->cmd_buf, 4);
  94. if (!buf) {
  95. - ret = fsl_qspi_runcmd(q, opcode, 0, 1);
  96. + ret = fsl_qspi_runcmd(q, opcode, to, 1);
  97. if (ret)
  98. return ret;
  99. --- a/include/linux/mtd/spi-nor.h
  100. +++ b/include/linux/mtd/spi-nor.h
  101. @@ -74,6 +74,10 @@
  102. /* Used for Spansion flashes only. */
  103. #define SPINOR_OP_BRWR 0x17 /* Bank register write */
  104. +/* Used for Spansion S25FS-S family flash only. */
  105. +#define SPINOR_OP_SPANSION_RDAR 0x65 /* Read any device register */
  106. +#define SPINOR_OP_SPANSION_WRAR 0x71 /* Write any device register */
  107. +
  108. /* Used for Micron flashes only. */
  109. #define SPINOR_OP_RD_EVCR 0x65 /* Read EVCR register */
  110. #define SPINOR_OP_WD_EVCR 0x61 /* Write EVCR register */