issi.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2005, Intec Automation Inc.
  4. * Copyright (C) 2014, Freescale Semiconductor, Inc.
  5. */
  6. #include <linux/mtd/spi-nor.h>
  7. #include "core.h"
  8. static int
  9. is25lp256_post_bfpt_fixups(struct spi_nor *nor,
  10. const struct sfdp_parameter_header *bfpt_header,
  11. const struct sfdp_bfpt *bfpt)
  12. {
  13. /*
  14. * IS25LP256 supports 4B opcodes, but the BFPT advertises
  15. * BFPT_DWORD1_ADDRESS_BYTES_3_ONLY.
  16. * Overwrite the number of address bytes advertised by the BFPT.
  17. */
  18. if ((bfpt->dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
  19. BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
  20. nor->params->addr_nbytes = 4;
  21. return 0;
  22. }
  23. static const struct spi_nor_fixups is25lp256_fixups = {
  24. .post_bfpt = is25lp256_post_bfpt_fixups,
  25. };
  26. static int pm25lv_nor_late_init(struct spi_nor *nor)
  27. {
  28. struct spi_nor_erase_map *map = &nor->params->erase_map;
  29. int i;
  30. /* The PM25LV series has a different 4k sector erase opcode */
  31. for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++)
  32. if (map->erase_type[i].size == 4096)
  33. map->erase_type[i].opcode = SPINOR_OP_BE_4K_PMC;
  34. return 0;
  35. }
  36. static const struct spi_nor_fixups pm25lv_nor_fixups = {
  37. .late_init = pm25lv_nor_late_init,
  38. };
  39. static const struct flash_info issi_nor_parts[] = {
  40. {
  41. .name = "pm25lv512",
  42. .sector_size = SZ_32K,
  43. .size = SZ_64K,
  44. .no_sfdp_flags = SECT_4K,
  45. .fixups = &pm25lv_nor_fixups
  46. }, {
  47. .name = "pm25lv010",
  48. .sector_size = SZ_32K,
  49. .size = SZ_128K,
  50. .no_sfdp_flags = SECT_4K,
  51. .fixups = &pm25lv_nor_fixups
  52. }, {
  53. .id = SNOR_ID(0x7f, 0x9d, 0x20),
  54. .name = "is25cd512",
  55. .sector_size = SZ_32K,
  56. .size = SZ_64K,
  57. .no_sfdp_flags = SECT_4K,
  58. }, {
  59. .id = SNOR_ID(0x7f, 0x9d, 0x46),
  60. .name = "pm25lq032",
  61. .size = SZ_4M,
  62. .no_sfdp_flags = SECT_4K,
  63. }, {
  64. .id = SNOR_ID(0x9d, 0x40, 0x13),
  65. .name = "is25lq040b",
  66. .size = SZ_512K,
  67. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
  68. }, {
  69. .id = SNOR_ID(0x9d, 0x60, 0x14),
  70. .name = "is25lp080d",
  71. .size = SZ_1M,
  72. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
  73. }, {
  74. .id = SNOR_ID(0x9d, 0x60, 0x15),
  75. .name = "is25lp016d",
  76. .size = SZ_2M,
  77. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
  78. }, {
  79. .id = SNOR_ID(0x9d, 0x60, 0x16),
  80. .name = "is25lp032",
  81. .size = SZ_4M,
  82. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ,
  83. }, {
  84. .id = SNOR_ID(0x9d, 0x60, 0x17),
  85. .name = "is25lp064",
  86. .size = SZ_8M,
  87. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ,
  88. }, {
  89. .id = SNOR_ID(0x9d, 0x60, 0x18),
  90. .name = "is25lp128",
  91. .size = SZ_16M,
  92. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ,
  93. }, {
  94. .id = SNOR_ID(0x9d, 0x60, 0x19),
  95. .name = "is25lp256",
  96. .fixups = &is25lp256_fixups,
  97. .fixup_flags = SPI_NOR_4B_OPCODES,
  98. }, {
  99. .id = SNOR_ID(0x9d, 0x70, 0x16),
  100. .name = "is25wp032",
  101. .size = SZ_4M,
  102. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
  103. }, {
  104. .id = SNOR_ID(0x9d, 0x70, 0x17),
  105. .size = SZ_8M,
  106. .name = "is25wp064",
  107. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
  108. }, {
  109. .id = SNOR_ID(0x9d, 0x70, 0x18),
  110. .name = "is25wp128",
  111. .size = SZ_16M,
  112. .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
  113. }, {
  114. .id = SNOR_ID(0x9d, 0x70, 0x19),
  115. .name = "is25wp256",
  116. .flags = SPI_NOR_QUAD_PP,
  117. .fixups = &is25lp256_fixups,
  118. .fixup_flags = SPI_NOR_4B_OPCODES,
  119. }
  120. };
  121. static void issi_nor_default_init(struct spi_nor *nor)
  122. {
  123. nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable;
  124. }
  125. static const struct spi_nor_fixups issi_fixups = {
  126. .default_init = issi_nor_default_init,
  127. };
  128. const struct spi_nor_manufacturer spi_nor_issi = {
  129. .name = "issi",
  130. .parts = issi_nor_parts,
  131. .nparts = ARRAY_SIZE(issi_nor_parts),
  132. .fixups = &issi_fixups,
  133. };