Linux 5.1.15
[linux/fpc-iii.git] / drivers / scsi / ufs / ufs_quirks.h
bloba9bbd34d6b160d1f73652b17e545106a4a97d05d
1 /*
2 * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #ifndef _UFS_QUIRKS_H_
16 #define _UFS_QUIRKS_H_
18 /* return true if s1 is a prefix of s2 */
19 #define STR_PRFX_EQUAL(s1, s2) !strncmp(s1, s2, strlen(s1))
21 #define UFS_ANY_VENDOR 0xFFFF
22 #define UFS_ANY_MODEL "ANY_MODEL"
24 #define UFS_VENDOR_TOSHIBA 0x198
25 #define UFS_VENDOR_SAMSUNG 0x1CE
26 #define UFS_VENDOR_SKHYNIX 0x1AD
28 /**
29 * ufs_dev_fix - ufs device quirk info
30 * @card: ufs card details
31 * @quirk: device quirk
33 struct ufs_dev_fix {
34 struct ufs_dev_desc card;
35 unsigned int quirk;
38 #define END_FIX { { 0 }, 0 }
40 /* add specific device quirk */
41 #define UFS_FIX(_vendor, _model, _quirk) { \
42 .card.wmanufacturerid = (_vendor),\
43 .card.model = (_model), \
44 .quirk = (_quirk), \
48 * Some vendor's UFS device sends back to back NACs for the DL data frames
49 * causing the host controller to raise the DFES error status. Sometimes
50 * such UFS devices send back to back NAC without waiting for new
51 * retransmitted DL frame from the host and in such cases it might be possible
52 * the Host UniPro goes into bad state without raising the DFES error
53 * interrupt. If this happens then all the pending commands would timeout
54 * only after respective SW command (which is generally too large).
56 * We can workaround such device behaviour like this:
57 * - As soon as SW sees the DL NAC error, it should schedule the error handler
58 * - Error handler would sleep for 50ms to see if there are any fatal errors
59 * raised by UFS controller.
60 * - If there are fatal errors then SW does normal error recovery.
61 * - If there are no fatal errors then SW sends the NOP command to device
62 * to check if link is alive.
63 * - If NOP command times out, SW does normal error recovery
64 * - If NOP command succeed, skip the error handling.
66 * If DL NAC error is seen multiple times with some vendor's UFS devices then
67 * enable this quirk to initiate quick error recovery and also silence related
68 * error logs to reduce spamming of kernel logs.
70 #define UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS (1 << 2)
73 * Few Toshiba UFS device models advertise RX_MIN_ACTIVATETIME_CAPABILITY as
74 * 600us which may not be enough for reliable hibern8 exit hardware sequence
75 * from UFS device.
76 * To workaround this issue, host should set its PA_TACTIVATE time to 1ms even
77 * if device advertises RX_MIN_ACTIVATETIME_CAPABILITY less than 1ms.
79 #define UFS_DEVICE_QUIRK_PA_TACTIVATE (1 << 4)
82 * It seems some UFS devices may keep drawing more than sleep current
83 * (atleast for 500us) from UFS rails (especially from VCCQ rail).
84 * To avoid this situation, add 2ms delay before putting these UFS
85 * rails in LPM mode.
87 #define UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM (1 << 6)
90 * Some UFS devices require host PA_TACTIVATE to be lower than device
91 * PA_TACTIVATE, enabling this quirk ensure this.
93 #define UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE (1 << 7)
96 * The max. value PA_SaveConfigTime is 250 (10us) but this is not enough for
97 * some vendors.
98 * Gear switch from PWM to HS may fail even with this max. PA_SaveConfigTime.
99 * Gear switch can be issued by host controller as an error recovery and any
100 * software delay will not help on this case so we need to increase
101 * PA_SaveConfigTime to >32us as per vendor recommendation.
103 #define UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME (1 << 8)
106 * Some UFS devices require VS_DebugSaveConfigTime is 0x10,
107 * enabling this quirk ensure this.
109 #define UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME (1 << 9)
111 #endif /* UFS_QUIRKS_H_ */