From acac4351e6207c8b9dd513a0fc7bfd4a34dc60ae Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Mon, 19 Mar 2018 16:04:47 +0800 Subject: [PATCH] clk: rockchip: Don't set invalid cached phase We cache the invalid cached phase when the clock provider be reparented from orphan to its real parent in the first place, thus we may mess up the initialization of MMC cards since we only set the default sample phase and drive phase later on. So we should skip to restore the invalid phase. Change-Id: I2d995a4ab53b824737718482f35fcaaf84767dfb Signed-off-by: Shawn Lin --- drivers/clk/rockchip/clk-mmc-phase.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/clk/rockchip/clk-mmc-phase.c b/drivers/clk/rockchip/clk-mmc-phase.c index 6e014a8650b7..65b99febed2c 100644 --- a/drivers/clk/rockchip/clk-mmc-phase.c +++ b/drivers/clk/rockchip/clk-mmc-phase.c @@ -171,6 +171,7 @@ static int rockchip_mmc_clk_rate_notify(struct notifier_block *nb, unsigned long event, void *data) { struct rockchip_mmc_clock *mmc_clock = to_rockchip_mmc_clock(nb); + struct clk_notifier_data *ndata = data; /* * rockchip_mmc_clk is mostly used by mmc controllers to sample @@ -179,10 +180,14 @@ static int rockchip_mmc_clk_rate_notify(struct notifier_block *nb, * and may break the data sampling. So here we try to restore the phase * for that case. */ + if (ndata->old_rate <= ndata->new_rate) + return NOTIFY_DONE; + if (event == PRE_RATE_CHANGE) mmc_clock->cached_phase = rockchip_mmc_get_phase(&mmc_clock->hw); - else if (event == POST_RATE_CHANGE) + else if (mmc_clock->cached_phase != -EINVAL && + event == POST_RATE_CHANGE) rockchip_mmc_set_phase(&mmc_clock->hw, mmc_clock->cached_phase); return NOTIFY_DONE;