ufs_quirks.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _UFS_QUIRKS_H_
  6. #define _UFS_QUIRKS_H_
  7. /* return true if s1 is a prefix of s2 */
  8. #define STR_PRFX_EQUAL(s1, s2) !strncmp(s1, s2, strlen(s1))
  9. #define UFS_ANY_VENDOR 0xFFFF
  10. #define UFS_ANY_MODEL "ANY_MODEL"
  11. #define UFS_VENDOR_MICRON 0x12C
  12. #define UFS_VENDOR_SAMSUNG 0x1CE
  13. #define UFS_VENDOR_SKHYNIX 0x1AD
  14. #define UFS_VENDOR_TOSHIBA 0x198
  15. #define UFS_VENDOR_WDC 0x145
  16. /**
  17. * ufs_dev_quirk - ufs device quirk info
  18. * @card: ufs card details
  19. * @quirk: device quirk
  20. */
  21. struct ufs_dev_quirk {
  22. u16 wmanufacturerid;
  23. const u8 *model;
  24. unsigned int quirk;
  25. };
  26. /*
  27. * Some vendor's UFS device sends back to back NACs for the DL data frames
  28. * causing the host controller to raise the DFES error status. Sometimes
  29. * such UFS devices send back to back NAC without waiting for new
  30. * retransmitted DL frame from the host and in such cases it might be possible
  31. * the Host UniPro goes into bad state without raising the DFES error
  32. * interrupt. If this happens then all the pending commands would timeout
  33. * only after respective SW command (which is generally too large).
  34. *
  35. * We can workaround such device behaviour like this:
  36. * - As soon as SW sees the DL NAC error, it should schedule the error handler
  37. * - Error handler would sleep for 50ms to see if there are any fatal errors
  38. * raised by UFS controller.
  39. * - If there are fatal errors then SW does normal error recovery.
  40. * - If there are no fatal errors then SW sends the NOP command to device
  41. * to check if link is alive.
  42. * - If NOP command times out, SW does normal error recovery
  43. * - If NOP command succeed, skip the error handling.
  44. *
  45. * If DL NAC error is seen multiple times with some vendor's UFS devices then
  46. * enable this quirk to initiate quick error recovery and also silence related
  47. * error logs to reduce spamming of kernel logs.
  48. */
  49. #define UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS (1 << 2)
  50. /*
  51. * Few Toshiba UFS device models advertise RX_MIN_ACTIVATETIME_CAPABILITY as
  52. * 600us which may not be enough for reliable hibern8 exit hardware sequence
  53. * from UFS device.
  54. * To workaround this issue, host should set its PA_TACTIVATE time to 1ms even
  55. * if device advertises RX_MIN_ACTIVATETIME_CAPABILITY less than 1ms.
  56. */
  57. #define UFS_DEVICE_QUIRK_PA_TACTIVATE (1 << 4)
  58. /*
  59. * It seems some UFS devices may keep drawing more than sleep current
  60. * (atleast for 500us) from UFS rails (especially from VCCQ rail).
  61. * To avoid this situation, add 2ms delay before putting these UFS
  62. * rails in LPM mode.
  63. */
  64. #define UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM (1 << 6)
  65. /*
  66. * Some UFS devices require host PA_TACTIVATE to be lower than device
  67. * PA_TACTIVATE, enabling this quirk ensure this.
  68. */
  69. #define UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE (1 << 7)
  70. /*
  71. * The max. value PA_SaveConfigTime is 250 (10us) but this is not enough for
  72. * some vendors.
  73. * Gear switch from PWM to HS may fail even with this max. PA_SaveConfigTime.
  74. * Gear switch can be issued by host controller as an error recovery and any
  75. * software delay will not help on this case so we need to increase
  76. * PA_SaveConfigTime to >32us as per vendor recommendation.
  77. */
  78. #define UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME (1 << 8)
  79. /*
  80. * Some UFS devices require VS_DebugSaveConfigTime is 0x10,
  81. * enabling this quirk ensure this.
  82. */
  83. #define UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME (1 << 9)
  84. /*
  85. * Some pre-3.1 UFS devices can support extended features by upgrading
  86. * the firmware. Enable this quirk to make UFS core driver probe and enable
  87. * supported features on such devices.
  88. */
  89. #define UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES (1 << 10)
  90. /*
  91. * Some UFS devices require delay after VCC power rail is turned-off.
  92. * Enable this quirk to introduce 5ms delays after VCC power-off during
  93. * suspend flow.
  94. */
  95. #define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11)
  96. /*
  97. * Some UFS devices require L2P entry should be swapped before being sent to the
  98. * UFS device for HPB READ command.
  99. */
  100. #define UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ (1 << 12)
  101. #endif /* UFS_QUIRKS_H_ */