issi.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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[BFPT_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 void 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. }
  35. static const struct spi_nor_fixups pm25lv_nor_fixups = {
  36. .late_init = pm25lv_nor_late_init,
  37. };
  38. static const struct flash_info issi_nor_parts[] = {
  39. /* ISSI */
  40. { "is25cd512", INFO(0x7f9d20, 0, 32 * 1024, 2)
  41. NO_SFDP_FLAGS(SECT_4K) },
  42. { "is25lq040b", INFO(0x9d4013, 0, 64 * 1024, 8)
  43. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  44. { "is25lp016d", INFO(0x9d6015, 0, 64 * 1024, 32)
  45. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  46. { "is25lp080d", INFO(0x9d6014, 0, 64 * 1024, 16)
  47. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  48. { "is25lp032", INFO(0x9d6016, 0, 64 * 1024, 64)
  49. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
  50. { "is25lp064", INFO(0x9d6017, 0, 64 * 1024, 128)
  51. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
  52. { "is25lp128", INFO(0x9d6018, 0, 64 * 1024, 256)
  53. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ) },
  54. { "is25lp256", INFO(0x9d6019, 0, 64 * 1024, 512)
  55. PARSE_SFDP
  56. FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
  57. .fixups = &is25lp256_fixups },
  58. { "is25wp032", INFO(0x9d7016, 0, 64 * 1024, 64)
  59. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  60. { "is25wp064", INFO(0x9d7017, 0, 64 * 1024, 128)
  61. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  62. { "is25wp128", INFO(0x9d7018, 0, 64 * 1024, 256)
  63. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
  64. { "is25wp256", INFO(0x9d7019, 0, 64 * 1024, 512)
  65. NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
  66. FIXUP_FLAGS(SPI_NOR_4B_OPCODES)
  67. FLAGS(SPI_NOR_QUAD_PP)
  68. .fixups = &is25lp256_fixups },
  69. /* PMC */
  70. { "pm25lv512", INFO(0, 0, 32 * 1024, 2)
  71. NO_SFDP_FLAGS(SECT_4K)
  72. .fixups = &pm25lv_nor_fixups
  73. },
  74. { "pm25lv010", INFO(0, 0, 32 * 1024, 4)
  75. NO_SFDP_FLAGS(SECT_4K)
  76. .fixups = &pm25lv_nor_fixups
  77. },
  78. { "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64)
  79. NO_SFDP_FLAGS(SECT_4K) },
  80. };
  81. static void issi_nor_default_init(struct spi_nor *nor)
  82. {
  83. nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable;
  84. }
  85. static const struct spi_nor_fixups issi_fixups = {
  86. .default_init = issi_nor_default_init,
  87. };
  88. const struct spi_nor_manufacturer spi_nor_issi = {
  89. .name = "issi",
  90. .parts = issi_nor_parts,
  91. .nparts = ARRAY_SIZE(issi_nor_parts),
  92. .fixups = &issi_fixups,
  93. };