MLK-16257: soc: imx: fix clock rate store issue in power off
authorShengjiu Wang <shengjiu.wang@freescale.com>
Thu, 24 Aug 2017 10:26:18 +0000 (18:26 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:38:24 +0000 (15:38 -0500)
commit246ebc007939292276a180f4bad9923759383d79
treed7a53972459cb2c9b402736d706942ba7fd4d793
parent4fa79c948bd037b98a5984d28bd0330140ad7dc0
MLK-16257: soc: imx: fix clock rate store issue in power off

In the case assign same clock in two device node in dts, which is
a parent clock used by two devices. In current design, we need to
assign this clock in two device node for clock rate recovery. In
this case, clock rate getted in imx8_pd_power_off() is zero for
second device, which will cause the clock recovery failed.

The calling sequence like this:

First device probe:
  --> of_clk_set_defaults
   --> clk_set_rate
    --> clk_core_set_rate_nolock: clk_core->rate = 0, so execute
        the calc rate and set rate. then update the clk_core->rate.

  --> imx8_pd_power_on: enable the power
  probe finished
  --> imx8_pd_power_off
   --> clk_get_rate: calc the rate, clk_core->rate !=0
   --> power off in scfw
        But scfw will set the "rate_div=0" for power is disabled.

Second device probe:
  --> of_clk_set_defaults
   --> clk_set_rate
    --> clk_core_set_rate_nolock: for the clk_core->rate == rate, so
        return directly.

  --> imx8_pd_power_on: enable the power
  probe finished
  --> imx8_pd_power_off
   --> clk_get_rate: calc the rate, but for the "rate_div ==0" in
       scfw, so the returned rate is 0. !!!!
       which will cause the clock recovery failed in pm_runtime_get_sync.

This patch is to use the clk_hw_get_rate instead the clk_get_rate, for
clk_hw_get_rate don't calc the rate, the clk_core->rate is what we want.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Reviewed-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
drivers/soc/imx/pm-domains.c