1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
9 /* return true if s1 is a prefix of s2 */
10 #define STR_PRFX_EQUAL(s1, s2) !strncmp(s1, s2, strlen(s1))
12 #define UFS_ANY_VENDOR 0xFFFF
13 #define UFS_ANY_MODEL "ANY_MODEL"
15 #define UFS_VENDOR_TOSHIBA 0x198
16 #define UFS_VENDOR_SAMSUNG 0x1CE
17 #define UFS_VENDOR_SKHYNIX 0x1AD
20 * ufs_dev_fix - ufs device quirk info
21 * @card: ufs card details
22 * @quirk: device quirk
32 /* add specific device quirk */
33 #define UFS_FIX(_vendor, _model, _quirk) { \
34 .wmanufacturerid = (_vendor),\
40 * Some vendor's UFS device sends back to back NACs for the DL data frames
41 * causing the host controller to raise the DFES error status. Sometimes
42 * such UFS devices send back to back NAC without waiting for new
43 * retransmitted DL frame from the host and in such cases it might be possible
44 * the Host UniPro goes into bad state without raising the DFES error
45 * interrupt. If this happens then all the pending commands would timeout
46 * only after respective SW command (which is generally too large).
48 * We can workaround such device behaviour like this:
49 * - As soon as SW sees the DL NAC error, it should schedule the error handler
50 * - Error handler would sleep for 50ms to see if there are any fatal errors
51 * raised by UFS controller.
52 * - If there are fatal errors then SW does normal error recovery.
53 * - If there are no fatal errors then SW sends the NOP command to device
54 * to check if link is alive.
55 * - If NOP command times out, SW does normal error recovery
56 * - If NOP command succeed, skip the error handling.
58 * If DL NAC error is seen multiple times with some vendor's UFS devices then
59 * enable this quirk to initiate quick error recovery and also silence related
60 * error logs to reduce spamming of kernel logs.
62 #define UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS (1 << 2)
65 * Few Toshiba UFS device models advertise RX_MIN_ACTIVATETIME_CAPABILITY as
66 * 600us which may not be enough for reliable hibern8 exit hardware sequence
68 * To workaround this issue, host should set its PA_TACTIVATE time to 1ms even
69 * if device advertises RX_MIN_ACTIVATETIME_CAPABILITY less than 1ms.
71 #define UFS_DEVICE_QUIRK_PA_TACTIVATE (1 << 4)
74 * It seems some UFS devices may keep drawing more than sleep current
75 * (atleast for 500us) from UFS rails (especially from VCCQ rail).
76 * To avoid this situation, add 2ms delay before putting these UFS
79 #define UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM (1 << 6)
82 * Some UFS devices require host PA_TACTIVATE to be lower than device
83 * PA_TACTIVATE, enabling this quirk ensure this.
85 #define UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE (1 << 7)
88 * The max. value PA_SaveConfigTime is 250 (10us) but this is not enough for
90 * Gear switch from PWM to HS may fail even with this max. PA_SaveConfigTime.
91 * Gear switch can be issued by host controller as an error recovery and any
92 * software delay will not help on this case so we need to increase
93 * PA_SaveConfigTime to >32us as per vendor recommendation.
95 #define UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME (1 << 8)
98 * Some UFS devices require VS_DebugSaveConfigTime is 0x10,
99 * enabling this quirk ensure this.
101 #define UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME (1 << 9)
103 #endif /* UFS_QUIRKS_H_ */