* [PATCH v2 0/5] MediaTek UFS vendor implemenation part III and Auto-Hibern8 fix
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
peter.wang, chun-hung.wu, andy.teng, Stanley Chu
Hi,
This series provides MediaTek vendor implementations and some general fixes.
- General fixes
- Fix Auto-Hibern8 error detection
- MediaTek vendor implementations
- Ensure UniPro is powered on before every link startup
- Support linkoff state during suspend
- Gate reference clock for Auto-Hibern8 case
v1 -> v2
- Fix and refine commit messages.
Stanley Chu (5):
scsi: ufs-mediatek: ensure UniPro is not powered down before linkup
scsi: ufs-mediatek: support linkoff state during suspend
scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
scsi: ufs: fix auto-hibern8 error detection
scsi: ufs-mediatek: gate ref-clk during Auto-Hibern8
drivers/scsi/ufs/ufs-mediatek.c | 65 +++++++++++++++++++++------------
drivers/scsi/ufs/ufs-mediatek.h | 12 ++++++
drivers/scsi/ufs/ufshcd.c | 3 +-
drivers/scsi/ufs/ufshcd.h | 6 +++
4 files changed, 62 insertions(+), 24 deletions(-)
--
2.18.0
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 0/5] MediaTek UFS vendor implemenation part III and Auto-Hibern8 fix
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
Hi,
This series provides MediaTek vendor implementations and some general fixes.
- General fixes
- Fix Auto-Hibern8 error detection
- MediaTek vendor implementations
- Ensure UniPro is powered on before every link startup
- Support linkoff state during suspend
- Gate reference clock for Auto-Hibern8 case
v1 -> v2
- Fix and refine commit messages.
Stanley Chu (5):
scsi: ufs-mediatek: ensure UniPro is not powered down before linkup
scsi: ufs-mediatek: support linkoff state during suspend
scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
scsi: ufs: fix auto-hibern8 error detection
scsi: ufs-mediatek: gate ref-clk during Auto-Hibern8
drivers/scsi/ufs/ufs-mediatek.c | 65 +++++++++++++++++++++------------
drivers/scsi/ufs/ufs-mediatek.h | 12 ++++++
drivers/scsi/ufs/ufshcd.c | 3 +-
drivers/scsi/ufs/ufshcd.h | 6 +++
4 files changed, 62 insertions(+), 24 deletions(-)
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 0/5] MediaTek UFS vendor implemenation part III and Auto-Hibern8 fix
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
Hi,
This series provides MediaTek vendor implementations and some general fixes.
- General fixes
- Fix Auto-Hibern8 error detection
- MediaTek vendor implementations
- Ensure UniPro is powered on before every link startup
- Support linkoff state during suspend
- Gate reference clock for Auto-Hibern8 case
v1 -> v2
- Fix and refine commit messages.
Stanley Chu (5):
scsi: ufs-mediatek: ensure UniPro is not powered down before linkup
scsi: ufs-mediatek: support linkoff state during suspend
scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
scsi: ufs: fix auto-hibern8 error detection
scsi: ufs-mediatek: gate ref-clk during Auto-Hibern8
drivers/scsi/ufs/ufs-mediatek.c | 65 +++++++++++++++++++++------------
drivers/scsi/ufs/ufs-mediatek.h | 12 ++++++
drivers/scsi/ufs/ufshcd.c | 3 +-
drivers/scsi/ufs/ufshcd.h | 6 +++
4 files changed, 62 insertions(+), 24 deletions(-)
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 1/5] scsi: ufs-mediatek: ensure UniPro is not powered down before linkup
2020-01-24 15:07 ` Stanley Chu
(?)
@ 2020-01-24 15:07 ` Stanley Chu
-1 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
peter.wang, chun-hung.wu, andy.teng, Stanley Chu
MediaTek Chipsets can enter proprietary UniPro low-power mode during
suspend while link is in hibern8 state. Make sure leaving low-power
mode before every link startup to prevent lockup in any possible error recovery
path.
In the same time, re-factor related funcitons to improve code readability.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 53eae5fe2ade..7ac838cc15d1 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -30,6 +30,11 @@
#define ufs_mtk_device_reset_ctrl(high, res) \
ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
+#define ufs_mtk_unipro_powerdown(hba, powerdown) \
+ ufshcd_dme_set(hba, \
+ UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), \
+ powerdown)
+
static void ufs_mtk_cfg_unipro_cg(struct ufs_hba *hba, bool enable)
{
u32 tmp;
@@ -290,6 +295,8 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
int ret;
u32 tmp;
+ ufs_mtk_unipro_powerdown(hba, 0);
+
/* disable deep stall */
ret = ufshcd_dme_get(hba, UIC_ARG_MIB(VS_SAVEPOWERCONTROL), &tmp);
if (ret)
@@ -390,9 +397,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
if (err)
return err;
- err = ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 0);
+ err = ufs_mtk_unipro_powerdown(hba, 0);
if (err)
return err;
@@ -413,14 +418,10 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba)
{
int err;
- err = ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 1);
+ err = ufs_mtk_unipro_powerdown(hba, 1);
if (err) {
/* Resume UniPro state for following error recovery */
- ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 0);
+ ufs_mtk_unipro_powerdown(hba, 0);
return err;
}
--
2.18.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 1/5] scsi: ufs-mediatek: ensure UniPro is not powered down before linkup
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
MediaTek Chipsets can enter proprietary UniPro low-power mode during
suspend while link is in hibern8 state. Make sure leaving low-power
mode before every link startup to prevent lockup in any possible error recovery
path.
In the same time, re-factor related funcitons to improve code readability.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 53eae5fe2ade..7ac838cc15d1 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -30,6 +30,11 @@
#define ufs_mtk_device_reset_ctrl(high, res) \
ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
+#define ufs_mtk_unipro_powerdown(hba, powerdown) \
+ ufshcd_dme_set(hba, \
+ UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), \
+ powerdown)
+
static void ufs_mtk_cfg_unipro_cg(struct ufs_hba *hba, bool enable)
{
u32 tmp;
@@ -290,6 +295,8 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
int ret;
u32 tmp;
+ ufs_mtk_unipro_powerdown(hba, 0);
+
/* disable deep stall */
ret = ufshcd_dme_get(hba, UIC_ARG_MIB(VS_SAVEPOWERCONTROL), &tmp);
if (ret)
@@ -390,9 +397,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
if (err)
return err;
- err = ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 0);
+ err = ufs_mtk_unipro_powerdown(hba, 0);
if (err)
return err;
@@ -413,14 +418,10 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba)
{
int err;
- err = ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 1);
+ err = ufs_mtk_unipro_powerdown(hba, 1);
if (err) {
/* Resume UniPro state for following error recovery */
- ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 0);
+ ufs_mtk_unipro_powerdown(hba, 0);
return err;
}
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 1/5] scsi: ufs-mediatek: ensure UniPro is not powered down before linkup
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
MediaTek Chipsets can enter proprietary UniPro low-power mode during
suspend while link is in hibern8 state. Make sure leaving low-power
mode before every link startup to prevent lockup in any possible error recovery
path.
In the same time, re-factor related funcitons to improve code readability.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 53eae5fe2ade..7ac838cc15d1 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -30,6 +30,11 @@
#define ufs_mtk_device_reset_ctrl(high, res) \
ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
+#define ufs_mtk_unipro_powerdown(hba, powerdown) \
+ ufshcd_dme_set(hba, \
+ UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), \
+ powerdown)
+
static void ufs_mtk_cfg_unipro_cg(struct ufs_hba *hba, bool enable)
{
u32 tmp;
@@ -290,6 +295,8 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba)
int ret;
u32 tmp;
+ ufs_mtk_unipro_powerdown(hba, 0);
+
/* disable deep stall */
ret = ufshcd_dme_get(hba, UIC_ARG_MIB(VS_SAVEPOWERCONTROL), &tmp);
if (ret)
@@ -390,9 +397,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
if (err)
return err;
- err = ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 0);
+ err = ufs_mtk_unipro_powerdown(hba, 0);
if (err)
return err;
@@ -413,14 +418,10 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba)
{
int err;
- err = ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 1);
+ err = ufs_mtk_unipro_powerdown(hba, 1);
if (err) {
/* Resume UniPro state for following error recovery */
- ufshcd_dme_set(hba,
- UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0),
- 0);
+ ufs_mtk_unipro_powerdown(hba, 0);
return err;
}
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 2/5] scsi: ufs-mediatek: support linkoff state during suspend
2020-01-24 15:07 ` Stanley Chu
(?)
@ 2020-01-24 15:07 ` Stanley Chu
-1 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
peter.wang, chun-hung.wu, andy.teng, Stanley Chu
If system suspend or runtime suspend mode is configured as
linkoff state, phy can be powered off and reference clock
can be gated in MediaTek Chipsets.
In the same time, remove redundant reference clock control
in suspend and resume callbacks because such control can be
well-handled in setup_clocks callback..
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 7ac838cc15d1..d78897a14905 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -167,7 +167,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
switch (status) {
case PRE_CHANGE:
- if (!on) {
+ if (!on && !ufshcd_is_link_active(hba)) {
ufs_mtk_setup_ref_clk(hba, on);
ret = phy_power_off(host->mphy);
}
@@ -437,10 +437,11 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
err = ufs_mtk_link_set_lpm(hba);
if (err)
return -EAGAIN;
- phy_power_off(host->mphy);
- ufs_mtk_setup_ref_clk(hba, false);
}
+ if (!ufshcd_is_link_active(hba))
+ phy_power_off(host->mphy);
+
return 0;
}
@@ -449,9 +450,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
int err;
- if (ufshcd_is_link_hibern8(hba)) {
- ufs_mtk_setup_ref_clk(hba, true);
+ if (!ufshcd_is_link_active(hba))
phy_power_on(host->mphy);
+
+ if (ufshcd_is_link_hibern8(hba)) {
err = ufs_mtk_link_set_hpm(hba);
if (err)
return err;
--
2.18.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 2/5] scsi: ufs-mediatek: support linkoff state during suspend
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
If system suspend or runtime suspend mode is configured as
linkoff state, phy can be powered off and reference clock
can be gated in MediaTek Chipsets.
In the same time, remove redundant reference clock control
in suspend and resume callbacks because such control can be
well-handled in setup_clocks callback..
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 7ac838cc15d1..d78897a14905 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -167,7 +167,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
switch (status) {
case PRE_CHANGE:
- if (!on) {
+ if (!on && !ufshcd_is_link_active(hba)) {
ufs_mtk_setup_ref_clk(hba, on);
ret = phy_power_off(host->mphy);
}
@@ -437,10 +437,11 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
err = ufs_mtk_link_set_lpm(hba);
if (err)
return -EAGAIN;
- phy_power_off(host->mphy);
- ufs_mtk_setup_ref_clk(hba, false);
}
+ if (!ufshcd_is_link_active(hba))
+ phy_power_off(host->mphy);
+
return 0;
}
@@ -449,9 +450,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
int err;
- if (ufshcd_is_link_hibern8(hba)) {
- ufs_mtk_setup_ref_clk(hba, true);
+ if (!ufshcd_is_link_active(hba))
phy_power_on(host->mphy);
+
+ if (ufshcd_is_link_hibern8(hba)) {
err = ufs_mtk_link_set_hpm(hba);
if (err)
return err;
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 2/5] scsi: ufs-mediatek: support linkoff state during suspend
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
If system suspend or runtime suspend mode is configured as
linkoff state, phy can be powered off and reference clock
can be gated in MediaTek Chipsets.
In the same time, remove redundant reference clock control
in suspend and resume callbacks because such control can be
well-handled in setup_clocks callback..
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 7ac838cc15d1..d78897a14905 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -167,7 +167,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
switch (status) {
case PRE_CHANGE:
- if (!on) {
+ if (!on && !ufshcd_is_link_active(hba)) {
ufs_mtk_setup_ref_clk(hba, on);
ret = phy_power_off(host->mphy);
}
@@ -437,10 +437,11 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
err = ufs_mtk_link_set_lpm(hba);
if (err)
return -EAGAIN;
- phy_power_off(host->mphy);
- ufs_mtk_setup_ref_clk(hba, false);
}
+ if (!ufshcd_is_link_active(hba))
+ phy_power_off(host->mphy);
+
return 0;
}
@@ -449,9 +450,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
int err;
- if (ufshcd_is_link_hibern8(hba)) {
- ufs_mtk_setup_ref_clk(hba, true);
+ if (!ufshcd_is_link_active(hba))
phy_power_on(host->mphy);
+
+ if (ufshcd_is_link_hibern8(hba)) {
err = ufs_mtk_link_set_hpm(hba);
if (err)
return err;
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 3/5] scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
2020-01-24 15:07 ` Stanley Chu
(?)
@ 2020-01-24 15:07 ` Stanley Chu
-1 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
peter.wang, chun-hung.wu, andy.teng, Stanley Chu
Auto-Hibern8 may be disabled by some vendors or sysfs
in runtime even if Auto-Hibern8 capability is supported
by host. Thus provide a way to detect if Auto-Hibern8 is
actually enabled for future related handlings.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufshcd.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 2ae6c7c8528c..81c71a3e3474 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -55,6 +55,7 @@
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/regulator/consumer.h>
+#include <linux/bitfield.h>
#include "unipro.h"
#include <asm/irq.h>
@@ -773,6 +774,11 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT);
}
+static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
+{
+ return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;
+}
+
#define ufshcd_writel(hba, val, reg) \
writel((val), (hba)->mmio_base + (reg))
#define ufshcd_readl(hba, reg) \
--
2.18.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 3/5] scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
Auto-Hibern8 may be disabled by some vendors or sysfs
in runtime even if Auto-Hibern8 capability is supported
by host. Thus provide a way to detect if Auto-Hibern8 is
actually enabled for future related handlings.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufshcd.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 2ae6c7c8528c..81c71a3e3474 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -55,6 +55,7 @@
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/regulator/consumer.h>
+#include <linux/bitfield.h>
#include "unipro.h"
#include <asm/irq.h>
@@ -773,6 +774,11 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT);
}
+static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
+{
+ return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;
+}
+
#define ufshcd_writel(hba, val, reg) \
writel((val), (hba)->mmio_base + (reg))
#define ufshcd_readl(hba, reg) \
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 3/5] scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
Auto-Hibern8 may be disabled by some vendors or sysfs
in runtime even if Auto-Hibern8 capability is supported
by host. Thus provide a way to detect if Auto-Hibern8 is
actually enabled for future related handlings.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufshcd.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 2ae6c7c8528c..81c71a3e3474 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -55,6 +55,7 @@
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/regulator/consumer.h>
+#include <linux/bitfield.h>
#include "unipro.h"
#include <asm/irq.h>
@@ -773,6 +774,11 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT);
}
+static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
+{
+ return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;
+}
+
#define ufshcd_writel(hba, val, reg) \
writel((val), (hba)->mmio_base + (reg))
#define ufshcd_readl(hba, reg) \
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
2020-01-24 15:07 ` Stanley Chu
(?)
@ 2020-01-24 15:07 ` Stanley Chu
-1 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
peter.wang, chun-hung.wu, andy.teng, Stanley Chu
If Auto-Hibern8 capability is supported by host but not actually
enabled, Auto-Hibern8 error shall not happen. Thus bypass
Auto-Hibern8 disabling case in ufshcd_is_auto_hibern8_error().
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufshcd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index abd0e6b05f79..214a3f373dd8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5479,7 +5479,8 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba)
static bool ufshcd_is_auto_hibern8_error(struct ufs_hba *hba,
u32 intr_mask)
{
- if (!ufshcd_is_auto_hibern8_supported(hba))
+ if (!ufshcd_is_auto_hibern8_supported(hba) ||
+ !ufshcd_is_auto_hibern8_enabled(hba))
return false;
if (!(intr_mask & UFSHCD_UIC_HIBERN8_MASK))
--
2.18.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
If Auto-Hibern8 capability is supported by host but not actually
enabled, Auto-Hibern8 error shall not happen. Thus bypass
Auto-Hibern8 disabling case in ufshcd_is_auto_hibern8_error().
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufshcd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index abd0e6b05f79..214a3f373dd8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5479,7 +5479,8 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba)
static bool ufshcd_is_auto_hibern8_error(struct ufs_hba *hba,
u32 intr_mask)
{
- if (!ufshcd_is_auto_hibern8_supported(hba))
+ if (!ufshcd_is_auto_hibern8_supported(hba) ||
+ !ufshcd_is_auto_hibern8_enabled(hba))
return false;
if (!(intr_mask & UFSHCD_UIC_HIBERN8_MASK))
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
If Auto-Hibern8 capability is supported by host but not actually
enabled, Auto-Hibern8 error shall not happen. Thus bypass
Auto-Hibern8 disabling case in ufshcd_is_auto_hibern8_error().
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufshcd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index abd0e6b05f79..214a3f373dd8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -5479,7 +5479,8 @@ static irqreturn_t ufshcd_update_uic_error(struct ufs_hba *hba)
static bool ufshcd_is_auto_hibern8_error(struct ufs_hba *hba,
u32 intr_mask)
{
- if (!ufshcd_is_auto_hibern8_supported(hba))
+ if (!ufshcd_is_auto_hibern8_supported(hba) ||
+ !ufshcd_is_auto_hibern8_enabled(hba))
return false;
if (!(intr_mask & UFSHCD_UIC_HIBERN8_MASK))
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 5/5] scsi: ufs-mediatek: gate ref-clk during Auto-Hibern8
2020-01-24 15:07 ` Stanley Chu
(?)
@ 2020-01-24 15:07 ` Stanley Chu
-1 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
peter.wang, chun-hung.wu, andy.teng, Stanley Chu
In current UFS driver design, hba->uic_link_state will not
be changed after link enters Hibern8 state by Auto-Hibern8 mechanism.
In this case, reference clock gating will be skipped unless special
handling is implemented in vendor's callbacks.
Support reference clock gating during Auto-Hibern8 period in
MediaTek Chipsets: If link state is already in Hibern8 while
Auto-Hibern8 feature is enabled, gate reference clock in
setup_clocks callback.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 38 +++++++++++++++++++++++----------
drivers/scsi/ufs/ufs-mediatek.h | 12 +++++++++++
2 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index d78897a14905..abf9dd75c42e 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -143,6 +143,17 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
return 0;
}
+static u32 ufs_mtk_link_get_state(struct ufs_hba *hba)
+{
+ u32 val;
+
+ ufshcd_writel(hba, 0x20, REG_UFS_DEBUG_SEL);
+ val = ufshcd_readl(hba, REG_UFS_PROBE);
+ val = val >> 28;
+
+ return val;
+}
+
/**
* ufs_mtk_setup_clocks - enables/disable clocks
* @hba: host controller instance
@@ -155,7 +166,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
enum ufs_notify_change_status status)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
- int ret = -EINVAL;
+ int ret = 0;
/*
* In case ufs_mtk_init() is not yet done, simply ignore.
@@ -165,19 +176,24 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
if (!host)
return 0;
- switch (status) {
- case PRE_CHANGE:
- if (!on && !ufshcd_is_link_active(hba)) {
+ if (!on && status == PRE_CHANGE) {
+ if (!ufshcd_is_link_active(hba)) {
ufs_mtk_setup_ref_clk(hba, on);
ret = phy_power_off(host->mphy);
+ } else {
+ /*
+ * Gate ref-clk if link state is in Hibern8
+ * triggered by Auto-Hibern8.
+ */
+ if (!ufshcd_can_hibern8_during_gating(hba) &&
+ ufshcd_is_auto_hibern8_enabled(hba) &&
+ ufs_mtk_link_get_state(hba) ==
+ VS_LINK_HIBER8)
+ ufs_mtk_setup_ref_clk(hba, on);
}
- break;
- case POST_CHANGE:
- if (on) {
- ret = phy_power_on(host->mphy);
- ufs_mtk_setup_ref_clk(hba, on);
- }
- break;
+ } else if (on && status == POST_CHANGE) {
+ ret = phy_power_on(host->mphy);
+ ufs_mtk_setup_ref_clk(hba, on);
}
return ret;
diff --git a/drivers/scsi/ufs/ufs-mediatek.h b/drivers/scsi/ufs/ufs-mediatek.h
index fccdd979d6fb..c32cb42c8942 100644
--- a/drivers/scsi/ufs/ufs-mediatek.h
+++ b/drivers/scsi/ufs/ufs-mediatek.h
@@ -53,6 +53,18 @@
#define VS_SAVEPOWERCONTROL 0xD0A6
#define VS_UNIPROPOWERDOWNCONTROL 0xD0A8
+/*
+ * Vendor specific link state
+ */
+enum {
+ VS_LINK_DISABLED = 0,
+ VS_LINK_DOWN = 1,
+ VS_LINK_UP = 2,
+ VS_LINK_HIBER8 = 3,
+ VS_LINK_LOST = 4,
+ VS_LINK_CFG = 5,
+};
+
/*
* SiP commands
*/
--
2.18.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 5/5] scsi: ufs-mediatek: gate ref-clk during Auto-Hibern8
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
In current UFS driver design, hba->uic_link_state will not
be changed after link enters Hibern8 state by Auto-Hibern8 mechanism.
In this case, reference clock gating will be skipped unless special
handling is implemented in vendor's callbacks.
Support reference clock gating during Auto-Hibern8 period in
MediaTek Chipsets: If link state is already in Hibern8 while
Auto-Hibern8 feature is enabled, gate reference clock in
setup_clocks callback.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 38 +++++++++++++++++++++++----------
drivers/scsi/ufs/ufs-mediatek.h | 12 +++++++++++
2 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index d78897a14905..abf9dd75c42e 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -143,6 +143,17 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
return 0;
}
+static u32 ufs_mtk_link_get_state(struct ufs_hba *hba)
+{
+ u32 val;
+
+ ufshcd_writel(hba, 0x20, REG_UFS_DEBUG_SEL);
+ val = ufshcd_readl(hba, REG_UFS_PROBE);
+ val = val >> 28;
+
+ return val;
+}
+
/**
* ufs_mtk_setup_clocks - enables/disable clocks
* @hba: host controller instance
@@ -155,7 +166,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
enum ufs_notify_change_status status)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
- int ret = -EINVAL;
+ int ret = 0;
/*
* In case ufs_mtk_init() is not yet done, simply ignore.
@@ -165,19 +176,24 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
if (!host)
return 0;
- switch (status) {
- case PRE_CHANGE:
- if (!on && !ufshcd_is_link_active(hba)) {
+ if (!on && status == PRE_CHANGE) {
+ if (!ufshcd_is_link_active(hba)) {
ufs_mtk_setup_ref_clk(hba, on);
ret = phy_power_off(host->mphy);
+ } else {
+ /*
+ * Gate ref-clk if link state is in Hibern8
+ * triggered by Auto-Hibern8.
+ */
+ if (!ufshcd_can_hibern8_during_gating(hba) &&
+ ufshcd_is_auto_hibern8_enabled(hba) &&
+ ufs_mtk_link_get_state(hba) ==
+ VS_LINK_HIBER8)
+ ufs_mtk_setup_ref_clk(hba, on);
}
- break;
- case POST_CHANGE:
- if (on) {
- ret = phy_power_on(host->mphy);
- ufs_mtk_setup_ref_clk(hba, on);
- }
- break;
+ } else if (on && status == POST_CHANGE) {
+ ret = phy_power_on(host->mphy);
+ ufs_mtk_setup_ref_clk(hba, on);
}
return ret;
diff --git a/drivers/scsi/ufs/ufs-mediatek.h b/drivers/scsi/ufs/ufs-mediatek.h
index fccdd979d6fb..c32cb42c8942 100644
--- a/drivers/scsi/ufs/ufs-mediatek.h
+++ b/drivers/scsi/ufs/ufs-mediatek.h
@@ -53,6 +53,18 @@
#define VS_SAVEPOWERCONTROL 0xD0A6
#define VS_UNIPROPOWERDOWNCONTROL 0xD0A8
+/*
+ * Vendor specific link state
+ */
+enum {
+ VS_LINK_DISABLED = 0,
+ VS_LINK_DOWN = 1,
+ VS_LINK_UP = 2,
+ VS_LINK_HIBER8 = 3,
+ VS_LINK_LOST = 4,
+ VS_LINK_CFG = 5,
+};
+
/*
* SiP commands
*/
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 5/5] scsi: ufs-mediatek: gate ref-clk during Auto-Hibern8
@ 2020-01-24 15:07 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-24 15:07 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: Stanley Chu, bvanassche, andy.teng, chun-hung.wu, kuohong.wang,
linux-kernel, cang, linux-mediatek, peter.wang, matthias.bgg,
beanhuo, linux-arm-kernel, asutoshd
In current UFS driver design, hba->uic_link_state will not
be changed after link enters Hibern8 state by Auto-Hibern8 mechanism.
In this case, reference clock gating will be skipped unless special
handling is implemented in vendor's callbacks.
Support reference clock gating during Auto-Hibern8 period in
MediaTek Chipsets: If link state is already in Hibern8 while
Auto-Hibern8 feature is enabled, gate reference clock in
setup_clocks callback.
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufs-mediatek.c | 38 +++++++++++++++++++++++----------
drivers/scsi/ufs/ufs-mediatek.h | 12 +++++++++++
2 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index d78897a14905..abf9dd75c42e 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -143,6 +143,17 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
return 0;
}
+static u32 ufs_mtk_link_get_state(struct ufs_hba *hba)
+{
+ u32 val;
+
+ ufshcd_writel(hba, 0x20, REG_UFS_DEBUG_SEL);
+ val = ufshcd_readl(hba, REG_UFS_PROBE);
+ val = val >> 28;
+
+ return val;
+}
+
/**
* ufs_mtk_setup_clocks - enables/disable clocks
* @hba: host controller instance
@@ -155,7 +166,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
enum ufs_notify_change_status status)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
- int ret = -EINVAL;
+ int ret = 0;
/*
* In case ufs_mtk_init() is not yet done, simply ignore.
@@ -165,19 +176,24 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
if (!host)
return 0;
- switch (status) {
- case PRE_CHANGE:
- if (!on && !ufshcd_is_link_active(hba)) {
+ if (!on && status == PRE_CHANGE) {
+ if (!ufshcd_is_link_active(hba)) {
ufs_mtk_setup_ref_clk(hba, on);
ret = phy_power_off(host->mphy);
+ } else {
+ /*
+ * Gate ref-clk if link state is in Hibern8
+ * triggered by Auto-Hibern8.
+ */
+ if (!ufshcd_can_hibern8_during_gating(hba) &&
+ ufshcd_is_auto_hibern8_enabled(hba) &&
+ ufs_mtk_link_get_state(hba) ==
+ VS_LINK_HIBER8)
+ ufs_mtk_setup_ref_clk(hba, on);
}
- break;
- case POST_CHANGE:
- if (on) {
- ret = phy_power_on(host->mphy);
- ufs_mtk_setup_ref_clk(hba, on);
- }
- break;
+ } else if (on && status == POST_CHANGE) {
+ ret = phy_power_on(host->mphy);
+ ufs_mtk_setup_ref_clk(hba, on);
}
return ret;
diff --git a/drivers/scsi/ufs/ufs-mediatek.h b/drivers/scsi/ufs/ufs-mediatek.h
index fccdd979d6fb..c32cb42c8942 100644
--- a/drivers/scsi/ufs/ufs-mediatek.h
+++ b/drivers/scsi/ufs/ufs-mediatek.h
@@ -53,6 +53,18 @@
#define VS_SAVEPOWERCONTROL 0xD0A6
#define VS_UNIPROPOWERDOWNCONTROL 0xD0A8
+/*
+ * Vendor specific link state
+ */
+enum {
+ VS_LINK_DISABLED = 0,
+ VS_LINK_DOWN = 1,
+ VS_LINK_UP = 2,
+ VS_LINK_HIBER8 = 3,
+ VS_LINK_LOST = 4,
+ VS_LINK_CFG = 5,
+};
+
/*
* SiP commands
*/
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 3/5] scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
2020-01-24 15:07 ` Stanley Chu
(?)
@ 2020-01-28 15:38 ` Bean Huo (beanhuo)
-1 siblings, 0 replies; 27+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-28 15:38 UTC (permalink / raw)
To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: asutoshd, cang, matthias.bgg, bvanassche, linux-mediatek,
linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
chun-hung.wu, andy.teng
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 3/5] scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
@ 2020-01-28 15:38 ` Bean Huo (beanhuo)
0 siblings, 0 replies; 27+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-28 15:38 UTC (permalink / raw)
To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
cang, linux-mediatek, peter.wang, matthias.bgg, linux-arm-kernel,
asutoshd
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 3/5] scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility
@ 2020-01-28 15:38 ` Bean Huo (beanhuo)
0 siblings, 0 replies; 27+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-28 15:38 UTC (permalink / raw)
To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
cang, linux-mediatek, peter.wang, matthias.bgg, linux-arm-kernel,
asutoshd
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
2020-01-24 15:07 ` Stanley Chu
(?)
@ 2020-01-28 15:52 ` Bean Huo (beanhuo)
-1 siblings, 0 replies; 27+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-28 15:52 UTC (permalink / raw)
To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: asutoshd, cang, matthias.bgg, bvanassche, linux-mediatek,
linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
chun-hung.wu, andy.teng
Hi, Stanley
Do you think it is necessary to add fixes tag, and combine this patch with previous patch to
single patch? That will be easier to down port to the older kernel.
>
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
@ 2020-01-28 15:52 ` Bean Huo (beanhuo)
0 siblings, 0 replies; 27+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-28 15:52 UTC (permalink / raw)
To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
cang, linux-mediatek, peter.wang, matthias.bgg, linux-arm-kernel,
asutoshd
Hi, Stanley
Do you think it is necessary to add fixes tag, and combine this patch with previous patch to
single patch? That will be easier to down port to the older kernel.
>
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
@ 2020-01-28 15:52 ` Bean Huo (beanhuo)
0 siblings, 0 replies; 27+ messages in thread
From: Bean Huo (beanhuo) @ 2020-01-28 15:52 UTC (permalink / raw)
To: Stanley Chu, linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
cang, linux-mediatek, peter.wang, matthias.bgg, linux-arm-kernel,
asutoshd
Hi, Stanley
Do you think it is necessary to add fixes tag, and combine this patch with previous patch to
single patch? That will be easier to down port to the older kernel.
>
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
2020-01-28 15:52 ` Bean Huo (beanhuo)
(?)
@ 2020-01-29 6:33 ` Stanley Chu
-1 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-29 6:33 UTC (permalink / raw)
To: Bean Huo (beanhuo)
Cc: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb,
bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
cang, linux-mediatek, peter.wang, matthias.bgg, linux-arm-kernel,
asutoshd
Hi Bean,
On Tue, 2020-01-28 at 15:52 +0000, Bean Huo (beanhuo) wrote:
> Hi, Stanley
> Do you think it is necessary to add fixes tag, and combine this patch with previous patch to
> single patch? That will be easier to down port to the older kernel.
OK! I will update this patch according to your suggestions in next
version.
Thanks,
Stanley
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
@ 2020-01-29 6:33 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-29 6:33 UTC (permalink / raw)
To: Bean Huo (beanhuo)
Cc: linux-scsi, martin.petersen, andy.teng, jejb, chun-hung.wu,
kuohong.wang, linux-kernel, avri.altman, cang, linux-mediatek,
peter.wang, alim.akhtar, matthias.bgg, asutoshd,
linux-arm-kernel, bvanassche
Hi Bean,
On Tue, 2020-01-28 at 15:52 +0000, Bean Huo (beanhuo) wrote:
> Hi, Stanley
> Do you think it is necessary to add fixes tag, and combine this patch with previous patch to
> single patch? That will be easier to down port to the older kernel.
OK! I will update this patch according to your suggestions in next
version.
Thanks,
Stanley
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [EXT] [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection
@ 2020-01-29 6:33 ` Stanley Chu
0 siblings, 0 replies; 27+ messages in thread
From: Stanley Chu @ 2020-01-29 6:33 UTC (permalink / raw)
To: Bean Huo (beanhuo)
Cc: linux-scsi, martin.petersen, andy.teng, jejb, chun-hung.wu,
kuohong.wang, linux-kernel, avri.altman, cang, linux-mediatek,
peter.wang, alim.akhtar, matthias.bgg, asutoshd,
linux-arm-kernel, bvanassche
Hi Bean,
On Tue, 2020-01-28 at 15:52 +0000, Bean Huo (beanhuo) wrote:
> Hi, Stanley
> Do you think it is necessary to add fixes tag, and combine this patch with previous patch to
> single patch? That will be easier to down port to the older kernel.
OK! I will update this patch according to your suggestions in next
version.
Thanks,
Stanley
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2020-01-29 6:34 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 15:07 [PATCH v2 0/5] MediaTek UFS vendor implemenation part III and Auto-Hibern8 fix Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` [PATCH v2 1/5] scsi: ufs-mediatek: ensure UniPro is not powered down before linkup Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` [PATCH v2 2/5] scsi: ufs-mediatek: support linkoff state during suspend Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` [PATCH v2 3/5] scsi: ufs: add ufshcd_is_auto_hibern8_enabled facility Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-28 15:38 ` [EXT] " Bean Huo (beanhuo)
2020-01-28 15:38 ` Bean Huo (beanhuo)
2020-01-28 15:38 ` Bean Huo (beanhuo)
2020-01-24 15:07 ` [PATCH v2 4/5] scsi: ufs: fix auto-hibern8 error detection Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-28 15:52 ` [EXT] " Bean Huo (beanhuo)
2020-01-28 15:52 ` Bean Huo (beanhuo)
2020-01-28 15:52 ` Bean Huo (beanhuo)
2020-01-29 6:33 ` Stanley Chu
2020-01-29 6:33 ` Stanley Chu
2020-01-29 6:33 ` Stanley Chu
2020-01-24 15:07 ` [PATCH v2 5/5] scsi: ufs-mediatek: gate ref-clk during Auto-Hibern8 Stanley Chu
2020-01-24 15:07 ` Stanley Chu
2020-01-24 15:07 ` Stanley Chu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.