diff options
author | Liu Ying <victor.liu@nxp.com> | 2018-06-15 14:09:47 +0800 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:32:16 +0800 |
commit | a1f262eda8553e2989b1c556e50966a31cfdf364 (patch) | |
tree | 88b235aa258bef18236e140e7aa5d863b664e8c7 /drivers/pwm | |
parent | 7a337aba1ddc239c80dbd4af355cf8713e928bc8 (diff) |
MLK-18617-3 pwm: imx: Use 32k clock if it is supplied
The PWM in i.MX8qxp MIPI subsystem needs to use the
'32k' clock to work properly. This patch gets this
clock in the PWM driver and uses it if it is supplied.
Signed-off-by: Liu Ying <victor.liu@nxp.com>
(cherry picked from commit a343cc44ee9aa4be408c51b02176c8d0970a698d)
Conflicts:
drivers/pwm/pwm-imx.c
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-imx.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index e942ab6c2fd3..46ecd46d1ede 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -51,6 +51,7 @@ struct imx_chip { struct clk *clk_per; struct clk *clk_ipg; + struct clk *clk_32k; void __iomem *mmio_base; @@ -64,17 +65,28 @@ static int imx_pwm_clk_prepare_enable(struct pwm_chip *chip) struct imx_chip *imx = to_imx_chip(chip); int ret; + if (imx->clk_32k) { + ret = clk_prepare_enable(imx->clk_32k); + if (ret) + goto err1; + } + ret = clk_prepare_enable(imx->clk_per); if (ret) - return ret; + goto err2; ret = clk_prepare_enable(imx->clk_ipg); - if (ret) { - clk_disable_unprepare(imx->clk_per); - return ret; - } + if (ret) + goto err3; return 0; +err3: + clk_disable_unprepare(imx->clk_per); +err2: + if (imx->clk_32k) + clk_disable_unprepare(imx->clk_32k); +err1: + return ret; } static void imx_pwm_clk_disable_unprepare(struct pwm_chip *chip) @@ -83,6 +95,8 @@ static void imx_pwm_clk_disable_unprepare(struct pwm_chip *chip) clk_disable_unprepare(imx->clk_ipg); clk_disable_unprepare(imx->clk_per); + if (imx->clk_32k) + clk_disable_unprepare(imx->clk_32k); } static int imx_pwm_config_v1(struct pwm_chip *chip, @@ -319,6 +333,10 @@ static int imx_pwm_probe(struct platform_device *pdev) return PTR_ERR(imx->clk_ipg); } + imx->clk_32k = devm_clk_get(&pdev->dev, "32k"); + if (IS_ERR(imx->clk_32k)) + imx->clk_32k = NULL; + imx->chip.ops = data->ops; imx->chip.dev = &pdev->dev; imx->chip.base = -1; |