MLK-16973-4 pwm: imx: Use ipg and per clks in ->config, ->enable and ->disable

For the i.MX8QM SoC, it turns out that both ipg and per clocks
are needed to be enabled when the PWM registers are configured.
Hence, we use the two clocks in the ->config, ->enable and
disable hooks.  For other SoCs unlike i.MX8QM, it could bring
some additional trivial power consumptions due to the additional
active ipg clock when PWM is enabled.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
This commit is contained in:
Liu Ying
2017-11-23 16:03:10 +08:00
committed by Nitin Garg
parent 673958a373
commit ce627dbfd7

View File

@ -206,13 +206,20 @@ static int imx_pwm_config(struct pwm_chip *chip,
struct imx_chip *imx = to_imx_chip(chip);
int ret;
ret = clk_prepare_enable(imx->clk_ipg);
ret = clk_prepare_enable(imx->clk_per);
if (ret)
return ret;
ret = clk_prepare_enable(imx->clk_ipg);
if (ret) {
clk_disable_unprepare(imx->clk_per);
return ret;
}
ret = imx->config(chip, pwm, duty_ns, period_ns);
clk_disable_unprepare(imx->clk_ipg);
clk_disable_unprepare(imx->clk_per);
return ret;
}
@ -226,6 +233,12 @@ static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
if (ret)
return ret;
ret = clk_prepare_enable(imx->clk_ipg);
if (ret) {
clk_disable_unprepare(imx->clk_per);
return ret;
}
imx->set_enable(chip, true);
return 0;
@ -237,6 +250,7 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
imx->set_enable(chip, false);
clk_disable_unprepare(imx->clk_ipg);
clk_disable_unprepare(imx->clk_per);
}