MLK-17790-2: CI_PI: add system and runtime suspend/resume
authorGuoniu.Zhou <guoniu.zhou@nxp.com>
Tue, 13 Mar 2018 10:08:16 +0000 (18:08 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
1. For QXP, after system suspend and resume, parent of pixel
and per clk will drop, so driver need to restore it. The rate
of pixel and per clk also will miss, so driver have to set it
in resume callback again.

2. I have to power off CI_PI subsystem power domain in resume
callback, otherwise setting clock parent will fail.

3. Driver need free gpio resouce after device do not use it.

Reviewed-by: Sandor.yu <sandor.yu@nxp.com>
Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit 986098a52e62b89d6f6f7afdb75d17d77649db59)

drivers/media/platform/imx8/ov5640_v3.c

index 1371ab8..16d6bea 100644 (file)
@@ -1419,18 +1419,23 @@ static int ov5640_probe(struct i2c_client *client,
        rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0);
        if (!gpio_is_valid(rst_gpio)) {
                dev_err(dev, "no sensor reset pin available\n");
+               devm_gpio_free(dev, pwn_gpio);
                return -EINVAL;
        }
        retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_LOW,
                                        "ov5640_reset");
-       if (retval < 0)
+       if (retval < 0) {
+               devm_gpio_free(dev, pwn_gpio);
                return retval;
+       }
 
        /* Set initial values for the sensor struct. */
        memset(&ov5640_data, 0, sizeof(ov5640_data));
        ov5640_data.sensor_clk = devm_clk_get(dev, "csi_mclk");
        if (IS_ERR(ov5640_data.sensor_clk)) {
                dev_err(dev, "get mclk failed\n");
+               devm_gpio_free(dev, pwn_gpio);
+               devm_gpio_free(dev, rst_gpio);
                return PTR_ERR(ov5640_data.sensor_clk);
        }