1 From 55231d8299d3dccde8588ed2e86c2bc0ef2e12ce Mon Sep 17 00:00:00 2001
2 From: Henry Chen <henryc.chen@mediatek.com>
3 Date: Mon, 4 Jan 2016 20:02:52 +0800
4 Subject: [PATCH 027/102] soc: mediatek: PMIC wrap: Clear the vldclr if state
5 machine stay on FSM_VLDCLR state.
7 Sometimes PMIC is too busy to send data in time to cause pmic wrap timeout,
8 because pmic wrap is waiting for FSM_VLDCLR after finishing WACS2_CMD. It
9 just return error when issue happened, so the state machine will stay on
10 FSM_VLDCLR state when data send back later by PMIC and timeout again in next
11 time because pmic wrap waiting for FSM_IDLE state at the beginning of the
14 Clear the vldclr when timeout if state machine stay on FSM_VLDCLR.
16 Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
17 Tested-by: Ricky Liang <jcliang@chromium.org>
18 Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
20 drivers/soc/mediatek/mtk-pmic-wrap.c | 22 ++++++++++++++++++++--
21 1 file changed, 20 insertions(+), 2 deletions(-)
23 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
24 +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
25 @@ -412,6 +412,20 @@ static bool pwrap_is_fsm_vldclr(struct p
26 return PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_WFVLDCLR;
30 + * Timeout issue sometimes caused by the last read command
31 + * failed because pmic wrap could not got the FSM_VLDCLR
32 + * in time after finishing WACS2_CMD. It made state machine
33 + * still on FSM_VLDCLR and timeout next time.
34 + * Check the status of FSM and clear the vldclr to recovery the
37 +static inline void pwrap_leave_fsm_vldclr(struct pmic_wrapper *wrp)
39 + if (pwrap_is_fsm_vldclr(wrp))
40 + pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
43 static bool pwrap_is_sync_idle(struct pmic_wrapper *wrp)
45 return pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_SYNC_IDLE0;
46 @@ -445,8 +459,10 @@ static int pwrap_write(struct pmic_wrapp
49 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
52 + pwrap_leave_fsm_vldclr(wrp);
56 pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata,
58 @@ -459,8 +475,10 @@ static int pwrap_read(struct pmic_wrappe
61 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
64 + pwrap_leave_fsm_vldclr(wrp);
68 pwrap_writel(wrp, (adr >> 1) << 16, PWRAP_WACS2_CMD);