summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ufs/ufs-mediatek.c
diff options
context:
space:
mode:
authorStanley Chu <stanley.chu@mediatek.com>2020-10-29 12:57:50 +0100
committerMartin K. Petersen <martin.petersen@oracle.com>2020-11-11 05:03:18 +0100
commit638e6271cac2d6eba8d5d6cfd6a6ae77715a8cf6 (patch)
treea9c5f9f5f2b2f65336ba3ce0b2a785e72cbec61c /drivers/scsi/ufs/ufs-mediatek.c
parentscsi: ufs: Add enums for UniPro version higher than 1.6 (diff)
downloadlinux-638e6271cac2d6eba8d5d6cfd6a6ae77715a8cf6.tar.xz
linux-638e6271cac2d6eba8d5d6cfd6a6ae77715a8cf6.zip
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. 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>
Diffstat (limited to 'drivers/scsi/ufs/ufs-mediatek.c')
-rw-r--r--drivers/scsi/ufs/ufs-mediatek.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 478774801196..7fed7630d36c 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -569,6 +569,24 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
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
* @hba: host controller instance
@@ -649,7 +667,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_req_params)
{
+ struct ufs_mtk_host *host = ufshcd_get_variant(hba);
struct ufs_dev_params host_cap;
+ u32 adapt_val;
int ret;
host_cap.tx_lanes = UFS_MTK_LIMIT_NUM_LANES_TX;
@@ -674,6 +694,16 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
__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;
}
@@ -724,6 +754,8 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
int ret;
u32 tmp;
+ ufs_mtk_get_controller_version(hba);
+
ret = ufs_mtk_unipro_set_lpm(hba, false);
if (ret)
return ret;