build/patch/kernel/archive/rockchip64-4.4/check/0011-add-imx219-power-down-gpio-control.patch

65 lines
1.8 KiB
Diff

From f1a5efacbc00f49c378234f77029c0c60f46e51f Mon Sep 17 00:00:00 2001
From: brian <brian@vamrs.com>
Date: Mon, 19 Nov 2018 17:27:05 +0800
Subject: [PATCH 11/97] add imx219 power down gpio control
Change-Id: I7f2cabaf82a4b936ac6da3fd5ffbecf95930d093
---
drivers/media/i2c/imx219.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index a05d5e9fabc2..b9434d1909a5 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -16,6 +16,7 @@
#include <linux/of_graph.h>
#include <linux/slab.h>
#include <linux/videodev2.h>
+#include <linux/gpio/consumer.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
@@ -215,6 +216,7 @@ struct imx219 {
struct media_pad pad;
struct v4l2_ctrl_handler ctrl_handler;
struct clk *clk;
+ struct gpio_desc *pwdn_gpio;
struct v4l2_rect crop_rect;
int hflip;
int vflip;
@@ -411,7 +413,17 @@ static int imx219_s_power(struct v4l2_subdev *sd, int on)
if (on) {
dev_dbg(&client->dev, "imx219 power on\n");
clk_prepare_enable(priv->clk);
+
+ if(!IS_ERR(priv->pwdn_gpio)) {
+ gpiod_set_value_cansleep(priv->pwdn_gpio, 1);
+ msleep(10);
+ }
} else if (!on) {
+
+ if(!IS_ERR(priv->pwdn_gpio)) {
+ gpiod_set_value_cansleep(priv->pwdn_gpio, 0);
+ }
+
dev_dbg(&client->dev, "imx219 power off\n");
clk_disable_unprepare(priv->clk);
}
@@ -893,6 +905,12 @@ static int imx219_probe(struct i2c_client *client,
return -EPROBE_DEFER;
}
+ priv->pwdn_gpio = devm_gpiod_get(&client->dev, "pwdn", GPIOD_OUT_LOW);
+ if (IS_ERR(priv->pwdn_gpio))
+ dev_info(&client->dev, "Failed to get pwdn-gpios\n");
+
+ gpiod_set_value_cansleep(priv->pwdn_gpio, 1);
+ msleep(5);
/* 1920 * 1080 by default */
priv->cur_mode = &supported_modes[0];
--
2.25.1