summaryrefslogtreecommitdiffstats
path: root/bsp/meta-rcar/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0413-media-i2c-max9288-fix-stream-on-off.patch
blob: f45837a2d1e7961fce5566c4d83d5b6b9aafdd3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 0bd5979e4ae470c914a941c97e178d71ecb8d7f9 Mon Sep 17 00:00:00 2001
From: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Date: Thu, 15 Aug 2019 14:18:51 +0300
Subject: [PATCH 3/3] media: i2c: max9288: fix stream on/off

The remote i2c write can fail seldom.
Implement write_verify.

Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
---
 drivers/media/i2c/soc_camera/max9288.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/soc_camera/max9288.c b/drivers/media/i2c/soc_camera/max9288.c
index dd57074..4840795 100644
--- a/drivers/media/i2c/soc_camera/max9288.c
+++ b/drivers/media/i2c/soc_camera/max9288.c
@@ -154,6 +154,27 @@ static char* ser_name(int id)
 	}
 }
 
+static void max9288_write_remote_verify(struct i2c_client *client, u8 reg, u8 val)
+{
+	struct max9288_priv *priv = i2c_get_clientdata(client);
+	int timeout;
+
+	for (timeout = 0; timeout < 10; timeout++) {
+		u8 val2 = 0;
+
+		reg8_write(client, reg, val);
+		reg8_read(client, reg, &val2);
+		if (val2 == val)
+			break;
+
+		usleep_range(1000, 1500);
+	}
+
+	if (timeout >= 10)
+		dev_err(&client->dev, "timeout remote write acked\n");
+}
+
+
 static void max9288_preinit(struct i2c_client *client, int addr)
 {
 
@@ -501,7 +522,7 @@ static int max9288_s_power(struct v4l2_subdev *sd, int on)
 	struct i2c_client *client = priv->client;
 
 	client->addr = priv->max9271_addr;			/* MAX9271-CAMx I2C new */
-	reg8_write(client, 0x04, on ? (conf_link ? 0x43 : 0x83) : 0x43); /* enable serial_link or conf_link */
+	max9288_write_remote_verify(client, 0x04, on ? (conf_link ? 0x43 : 0x83) : 0x43); /* enable serial_link or conf_link */
 	usleep_range(2000, 2500);				/* wait 2ms after changing reverse_control */
 	client->addr = priv->des_addr;				/* MAX9288-CAMx I2C */
 
-- 
2.7.4