From 8241a96db8e7365a23b5ba76a33af47fcc6b7ee8 Mon Sep 17 00:00:00 2001
From: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Date: Tue, 12 Feb 2019 22:29:24 +0300
Subject: [PATCH 102/122] lvds: OV495: fix reset gpio handling

This fixes gpio reset handling on OV495 imager
GPIO0 - NRESET
GPIO1 - NC (no FSIN!)
kernel parameter requred: ti9x4.gpio0=1

Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
---
 drivers/media/i2c/soc_camera/ov106xx.c      | 12 ++++++------
 drivers/media/i2c/soc_camera/ov495_ov2775.c |  5 +----
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/ov106xx.c b/drivers/media/i2c/soc_camera/ov106xx.c
index 8962ab9..d641907 100644
--- a/drivers/media/i2c/soc_camera/ov106xx.c
+++ b/drivers/media/i2c/soc_camera/ov106xx.c
@@ -73,6 +73,12 @@ static int ov106xx_probe(struct i2c_client *client,
 		goto out;
 	}
 
+	ret = ov495_probe(client, did);
+	if (!ret) {
+		chip_id = ID_OV495_OV2775;
+		goto out;
+	}
+
 	ret = ov10640_probe(client, did);
 	if (!ret) {
 		chip_id = ID_OV10640;
@@ -91,12 +97,6 @@ static int ov106xx_probe(struct i2c_client *client,
 		goto out;
 	}
 
-	ret = ov495_probe(client, did);
-	if (!ret) {
-		chip_id = ID_OV495_OV2775;
-		goto out;
-	}
-
 	ret = ar0132_probe(client, did);
 	if (!ret) {
 		chip_id = ID_AR0132;
diff --git a/drivers/media/i2c/soc_camera/ov495_ov2775.c b/drivers/media/i2c/soc_camera/ov495_ov2775.c
index 34b2f46..aee8145 100644
--- a/drivers/media/i2c/soc_camera/ov495_ov2775.c
+++ b/drivers/media/i2c/soc_camera/ov495_ov2775.c
@@ -503,10 +503,7 @@ static int ov495_parse_dt(struct device_node *np, struct ov495_priv *priv)
 		usleep_range(2000, 2500);				/* wait 2ms */
 		reg8_write(client, 0x65, tmp_addr << 1);		/* Sensor translated I2C address */
 		reg8_write(client, 0x5d, OV495_I2C_ADDR << 1);		/* Sensor native I2C address */
-
-		reg8_write(client, 0x6e, 0x9a);				/* GPIO0 - fsin, GPIO1 - resetb */
-		/* TODO: why too long? move logic to workqueue? */
-		mdelay(350);						/* time needed to boot all sensor IPs */
+		usleep_range(2000, 2500);				/* wait 2ms */
 	}
 	client->addr = tmp_addr;
 
-- 
2.7.4

