/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.3*/45#ifndef _UFS_QUIRKS_H_6#define _UFS_QUIRKS_H_78/* return true if s1 is a prefix of s2 */9#define STR_PRFX_EQUAL(s1, s2) !strncmp(s1, s2, strlen(s1))1011#define UFS_ANY_VENDOR 0xFFFF12#define UFS_ANY_MODEL "ANY_MODEL"1314#define UFS_VENDOR_MICRON 0x12C15#define UFS_VENDOR_SAMSUNG 0x1CE16#define UFS_VENDOR_SKHYNIX 0x1AD17#define UFS_VENDOR_TOSHIBA 0x19818#define UFS_VENDOR_WDC 0x1451920/**21* ufs_dev_quirk - ufs device quirk info22* @card: ufs card details23* @quirk: device quirk24*/25struct ufs_dev_quirk {26u16 wmanufacturerid;27const u8 *model;28unsigned int quirk;29};3031/*32* Some vendor's UFS device sends back to back NACs for the DL data frames33* causing the host controller to raise the DFES error status. Sometimes34* such UFS devices send back to back NAC without waiting for new35* retransmitted DL frame from the host and in such cases it might be possible36* the Host UniPro goes into bad state without raising the DFES error37* interrupt. If this happens then all the pending commands would timeout38* only after respective SW command (which is generally too large).39*40* We can workaround such device behaviour like this:41* - As soon as SW sees the DL NAC error, it should schedule the error handler42* - Error handler would sleep for 50ms to see if there are any fatal errors43* raised by UFS controller.44* - If there are fatal errors then SW does normal error recovery.45* - If there are no fatal errors then SW sends the NOP command to device46* to check if link is alive.47* - If NOP command times out, SW does normal error recovery48* - If NOP command succeed, skip the error handling.49*50* If DL NAC error is seen multiple times with some vendor's UFS devices then51* enable this quirk to initiate quick error recovery and also silence related52* error logs to reduce spamming of kernel logs.53*/54#define UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS (1 << 2)5556/*57* Few Toshiba UFS device models advertise RX_MIN_ACTIVATETIME_CAPABILITY as58* 600us which may not be enough for reliable hibern8 exit hardware sequence59* from UFS device.60* To workaround this issue, host should set its PA_TACTIVATE time to 1ms even61* if device advertises RX_MIN_ACTIVATETIME_CAPABILITY less than 1ms.62*/63#define UFS_DEVICE_QUIRK_PA_TACTIVATE (1 << 4)6465/*66* It seems some UFS devices may keep drawing more than sleep current67* (atleast for 500us) from UFS rails (especially from VCCQ rail).68* To avoid this situation, add 2ms delay before putting these UFS69* rails in LPM mode.70*/71#define UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM (1 << 6)7273/*74* Some UFS devices require host PA_TACTIVATE to be lower than device75* PA_TACTIVATE, enabling this quirk ensure this.76*/77#define UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE (1 << 7)7879/*80* The max. value PA_SaveConfigTime is 250 (10us) but this is not enough for81* some vendors.82* Gear switch from PWM to HS may fail even with this max. PA_SaveConfigTime.83* Gear switch can be issued by host controller as an error recovery and any84* software delay will not help on this case so we need to increase85* PA_SaveConfigTime to >32us as per vendor recommendation.86*/87#define UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME (1 << 8)8889/*90* Some UFS devices require VS_DebugSaveConfigTime is 0x10,91* enabling this quirk ensure this.92*/93#define UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME (1 << 9)9495/*96* Some pre-3.1 UFS devices can support extended features by upgrading97* the firmware. Enable this quirk to make UFS core driver probe and enable98* supported features on such devices.99*/100#define UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES (1 << 10)101102/*103* Some UFS devices require delay after VCC power rail is turned-off.104* Enable this quirk to introduce 5ms delays after VCC power-off during105* suspend flow.106*/107#define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11)108109/*110* Some ufs devices may need more time to be in hibern8 before exiting.111* Enable this quirk to give it an additional 100us.112*/113#define UFS_DEVICE_QUIRK_PA_HIBER8TIME (1 << 12)114115#endif /* UFS_QUIRKS_H_ */116117118