mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
BACKPORT: scsi: ufs-mediatek: Add HS-G4 support
Provide HS-G4 support in MediaTek UFS platforms.
To support HS-G4, introduce mechanism to get the MediaTek UFS controller
version. With such information, driver can make right decision to apply
different configurations in different controllers.
Bug: 188004633
Change-Id: Iee8b96bac9f1796693dc20f5c7d854ba7ae71939
(cherry picked from commit 638e6271ca)
[Stanley: Resolved minor conflict in drivers/scsi/ufs-mediatek.c]
[Stanley: Resolved minor conflict in drivers/scsi/ufs-mediatek.h]
Link: https://lore.kernel.org/r/20201029115750.24391-7-stanley.chu@mediatek.com
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
371de759e9
commit
ff128c2d77
@@ -510,6 +510,24 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ufs_mtk_get_controller_version(struct ufs_hba *hba)
|
||||||
|
{
|
||||||
|
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
|
||||||
|
int ret, ver = 0;
|
||||||
|
|
||||||
|
if (host->hw_ver.major)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Set default (minimum) version anyway */
|
||||||
|
host->hw_ver.major = 2;
|
||||||
|
|
||||||
|
ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_LOCALVERINFO), &ver);
|
||||||
|
if (!ret) {
|
||||||
|
if (ver >= UFS_UNIPRO_VER_1_8)
|
||||||
|
host->hw_ver.major = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ufs_mtk_init - find other essential mmio bases
|
* ufs_mtk_init - find other essential mmio bases
|
||||||
* @hba: host controller instance
|
* @hba: host controller instance
|
||||||
@@ -590,7 +608,9 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
|
|||||||
struct ufs_pa_layer_attr *dev_max_params,
|
struct ufs_pa_layer_attr *dev_max_params,
|
||||||
struct ufs_pa_layer_attr *dev_req_params)
|
struct ufs_pa_layer_attr *dev_req_params)
|
||||||
{
|
{
|
||||||
|
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
|
||||||
struct ufs_dev_params host_cap;
|
struct ufs_dev_params host_cap;
|
||||||
|
u32 adapt_val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
host_cap.tx_lanes = UFS_MTK_LIMIT_NUM_LANES_TX;
|
host_cap.tx_lanes = UFS_MTK_LIMIT_NUM_LANES_TX;
|
||||||
@@ -615,6 +635,16 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
|
|||||||
__func__);
|
__func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (host->hw_ver.major >= 3) {
|
||||||
|
if (dev_req_params->gear_tx == UFS_HS_G4)
|
||||||
|
adapt_val = PA_INITIAL_ADAPT;
|
||||||
|
else
|
||||||
|
adapt_val = PA_NO_ADAPT;
|
||||||
|
ufshcd_dme_set(hba,
|
||||||
|
UIC_ARG_MIB(PA_TXHSADAPTTYPE),
|
||||||
|
adapt_val);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,6 +695,8 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
|
|||||||
int ret;
|
int ret;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
|
|
||||||
|
ufs_mtk_get_controller_version(hba);
|
||||||
|
|
||||||
ret = ufs_mtk_unipro_set_pm(hba, false);
|
ret = ufs_mtk_unipro_set_pm(hba, false);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -35,8 +35,8 @@
|
|||||||
*/
|
*/
|
||||||
#define UFS_MTK_LIMIT_NUM_LANES_RX 2
|
#define UFS_MTK_LIMIT_NUM_LANES_RX 2
|
||||||
#define UFS_MTK_LIMIT_NUM_LANES_TX 2
|
#define UFS_MTK_LIMIT_NUM_LANES_TX 2
|
||||||
#define UFS_MTK_LIMIT_HSGEAR_RX UFS_HS_G3
|
#define UFS_MTK_LIMIT_HSGEAR_RX UFS_HS_G4
|
||||||
#define UFS_MTK_LIMIT_HSGEAR_TX UFS_HS_G3
|
#define UFS_MTK_LIMIT_HSGEAR_TX UFS_HS_G4
|
||||||
#define UFS_MTK_LIMIT_PWMGEAR_RX UFS_PWM_G4
|
#define UFS_MTK_LIMIT_PWMGEAR_RX UFS_PWM_G4
|
||||||
#define UFS_MTK_LIMIT_PWMGEAR_TX UFS_PWM_G4
|
#define UFS_MTK_LIMIT_PWMGEAR_TX UFS_PWM_G4
|
||||||
#define UFS_MTK_LIMIT_RX_PWR_PWM SLOW_MODE
|
#define UFS_MTK_LIMIT_RX_PWR_PWM SLOW_MODE
|
||||||
@@ -104,6 +104,12 @@ struct ufs_mtk_crypt_cfg {
|
|||||||
int vcore_volt;
|
int vcore_volt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ufs_mtk_hw_ver {
|
||||||
|
u8 step;
|
||||||
|
u8 minor;
|
||||||
|
u8 major;
|
||||||
|
};
|
||||||
|
|
||||||
struct ufs_mtk_host_cfg {
|
struct ufs_mtk_host_cfg {
|
||||||
enum ufs_mtk_host_caps caps;
|
enum ufs_mtk_host_caps caps;
|
||||||
};
|
};
|
||||||
@@ -113,6 +119,7 @@ struct ufs_mtk_host {
|
|||||||
struct phy *mphy;
|
struct phy *mphy;
|
||||||
struct ufs_mtk_host_cfg *cfg;
|
struct ufs_mtk_host_cfg *cfg;
|
||||||
struct ufs_mtk_crypt_cfg *crypt;
|
struct ufs_mtk_crypt_cfg *crypt;
|
||||||
|
struct ufs_mtk_hw_ver hw_ver;
|
||||||
enum ufs_mtk_host_caps caps;
|
enum ufs_mtk_host_caps caps;
|
||||||
struct reset_control *hci_reset;
|
struct reset_control *hci_reset;
|
||||||
struct reset_control *unipro_reset;
|
struct reset_control *unipro_reset;
|
||||||
|
|||||||
Reference in New Issue
Block a user