2016-05-23 17:20:20 +08:00
|
|
|
From 55231d8299d3dccde8588ed2e86c2bc0ef2e12ce Mon Sep 17 00:00:00 2001
|
2016-03-22 04:42:51 +08:00
|
|
|
From: Henry Chen <henryc.chen@mediatek.com>
|
|
|
|
Date: Mon, 4 Jan 2016 20:02:52 +0800
|
2016-05-23 17:20:20 +08:00
|
|
|
Subject: [PATCH 027/102] soc: mediatek: PMIC wrap: Clear the vldclr if state
|
2016-03-22 04:42:51 +08:00
|
|
|
machine stay on FSM_VLDCLR state.
|
|
|
|
|
|
|
|
Sometimes PMIC is too busy to send data in time to cause pmic wrap timeout,
|
|
|
|
because pmic wrap is waiting for FSM_VLDCLR after finishing WACS2_CMD. It
|
|
|
|
just return error when issue happened, so the state machine will stay on
|
|
|
|
FSM_VLDCLR state when data send back later by PMIC and timeout again in next
|
|
|
|
time because pmic wrap waiting for FSM_IDLE state at the beginning of the
|
|
|
|
read/write function.
|
|
|
|
|
|
|
|
Clear the vldclr when timeout if state machine stay on FSM_VLDCLR.
|
|
|
|
|
|
|
|
Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
|
|
|
|
Tested-by: Ricky Liang <jcliang@chromium.org>
|
|
|
|
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
|
|
|
---
|
|
|
|
drivers/soc/mediatek/mtk-pmic-wrap.c | 22 ++++++++++++++++++++--
|
|
|
|
1 file changed, 20 insertions(+), 2 deletions(-)
|
|
|
|
|
2016-05-23 17:20:20 +08:00
|
|
|
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
|
|
|
|
index 105597a..696071b 100644
|
2016-03-22 04:42:51 +08:00
|
|
|
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
|
|
|
|
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
|
2016-05-23 17:20:20 +08:00
|
|
|
@@ -412,6 +412,20 @@ static bool pwrap_is_fsm_vldclr(struct pmic_wrapper *wrp)
|
2016-03-22 04:42:51 +08:00
|
|
|
return PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_WFVLDCLR;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Timeout issue sometimes caused by the last read command
|
|
|
|
+ * failed because pmic wrap could not got the FSM_VLDCLR
|
|
|
|
+ * in time after finishing WACS2_CMD. It made state machine
|
|
|
|
+ * still on FSM_VLDCLR and timeout next time.
|
|
|
|
+ * Check the status of FSM and clear the vldclr to recovery the
|
|
|
|
+ * error.
|
|
|
|
+ */
|
|
|
|
+static inline void pwrap_leave_fsm_vldclr(struct pmic_wrapper *wrp)
|
|
|
|
+{
|
|
|
|
+ if (pwrap_is_fsm_vldclr(wrp))
|
|
|
|
+ pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static bool pwrap_is_sync_idle(struct pmic_wrapper *wrp)
|
|
|
|
{
|
|
|
|
return pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_SYNC_IDLE0;
|
2016-05-23 17:20:20 +08:00
|
|
|
@@ -445,8 +459,10 @@ static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
|
2016-03-22 04:42:51 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
|
|
|
|
- if (ret)
|
|
|
|
+ if (ret) {
|
|
|
|
+ pwrap_leave_fsm_vldclr(wrp);
|
|
|
|
return ret;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata,
|
|
|
|
PWRAP_WACS2_CMD);
|
2016-05-23 17:20:20 +08:00
|
|
|
@@ -459,8 +475,10 @@ static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
|
2016-03-22 04:42:51 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
|
|
|
|
- if (ret)
|
|
|
|
+ if (ret) {
|
|
|
|
+ pwrap_leave_fsm_vldclr(wrp);
|
|
|
|
return ret;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
pwrap_writel(wrp, (adr >> 1) << 16, PWRAP_WACS2_CMD);
|
|
|
|
|
2016-05-23 17:20:20 +08:00
|
|
|
--
|
|
|
|
1.7.10.4
|
|
|
|
|