summaryrefslogtreecommitdiffstats
path: root/bsp/meta-rcar/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0137-lvds-poll-ub960-deserializer-lock-status.patch
blob: 4d6ef176a7b75f04ed61a7631ca17f8852a49b86 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
From df920df1a7a26dd4b49f90d4ce4e94b2541348d6 Mon Sep 17 00:00:00 2001
From: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Date: Thu, 3 Jan 2019 23:24:03 +0300
Subject: [PATCH 086/122] lvds: poll ub960 deserializer lock status

Poll FPDLINK lock status instead delay

Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
---
 drivers/media/i2c/soc_camera/ti9x4.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/soc_camera/ti9x4.c b/drivers/media/i2c/soc_camera/ti9x4.c
index d03c0f9..f0b782f 100644
--- a/drivers/media/i2c/soc_camera/ti9x4.c
+++ b/drivers/media/i2c/soc_camera/ti9x4.c
@@ -278,7 +278,9 @@ static void ti9x4_fpdlink3_setup(struct i2c_client *client, int idx)
 static int ti9x4_initialize(struct i2c_client *client)
 {
 	struct ti9x4_priv *priv = i2c_get_clientdata(client);
-	int idx;
+	int idx, timeout;
+	u8 port_sts1 = 0, port_sts2 = 0;
+	int tmp_addr;
 
 	dev_info(&client->dev, "LINKs=%d, LANES=%d, FORWARDING=%s, CABLE=%s, ID=%s\n",
 			       priv->links, priv->lanes, priv->forwarding_mode, priv->is_coax ? "coax" : "stp", priv->chip_id);
@@ -294,12 +296,35 @@ static int ti9x4_initialize(struct i2c_client *client)
 		ti9x4_fpdlink3_setup(client, idx);
 	}
 
-	/* extra delay to wait imager power up */
-	if (priv->poc_delay)
-		mdelay(350);
-
 	client->addr = priv->des_addr;
 
+	/* check lock status */
+	for (timeout = 500 / priv->links; timeout > 0; timeout--) {
+		for (idx = 0; idx < priv->links; idx++) {
+			reg8_write(client, 0x4c, (idx << 4) | (1 << idx));	/* Select RX port number */
+			usleep_range(1000, 1500);				/* wait 1ms */
+			reg8_read(client, 0x4d, &port_sts1);			/* Lock status */
+			reg8_read(client, 0x4e, &port_sts2);			/* Freq stable */
+
+			if (port_sts1 & 0x1) {
+				tmp_addr = client->addr;
+				client->addr = priv->ti9x3_addr_map[idx];	/* TI9X3 I2C addr */
+				reg8_write(client, 0x0d, 0xf0);			/* Enable all remote GPIOs */
+				reg8_write(client, 0x0e, 0xf0);			/* Enable serializer GPIOs */
+				client->addr = tmp_addr;
+			}
+
+			if ((port_sts1 & 0x1) && (port_sts2 & 0x4))
+				goto out;
+		}
+	}
+
+	if (!timeout)
+		dev_info(&client->dev, "Receiver is not locked\n");
+out:
+	if (priv->poc_delay)
+		mdelay(100);
+
 	return 0;
 }
 
-- 
2.7.4