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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
From 3eb6986dcd340226956239c94adceff9e7a4f7af Mon Sep 17 00:00:00 2001
From: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Date: Tue, 19 Mar 2019 13:51:26 +0300
Subject: [PATCH 108/122] MAX9286: adjust POC trigger for unstable link
Enhance POC trgger on camera detect fails
Add lock/link status show
Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
---
drivers/media/i2c/soc_camera/max9286.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/media/i2c/soc_camera/max9286.c b/drivers/media/i2c/soc_camera/max9286.c
index c69be50..3184ff1 100644
--- a/drivers/media/i2c/soc_camera/max9286.c
+++ b/drivers/media/i2c/soc_camera/max9286.c
@@ -108,6 +108,10 @@ static int active_low_resetb;
module_param(active_low_resetb, int, 0644);
MODULE_PARM_DESC(active_low_resetb, " Serializer GPIO reset level (default: 0 - active high)");
+static int timeout_n = 100;
+module_param(timeout_n, int, 0644);
+MODULE_PARM_DESC(timeout_n, " Timeout of link detection (default: 100 retries)");
+
static int poc_delay = 50;
module_param(poc_delay, int, 0644);
MODULE_PARM_DESC(poc_delay, " Delay in ms after POC enable (default: 50 ms)");
@@ -270,9 +274,9 @@ static void max9286_postinit(struct i2c_client *client, int addr)
static int max9286_reverse_channel_setup(struct i2c_client *client, int idx)
{
struct max9286_priv *priv = i2c_get_clientdata(client);
- u8 val = 0;
+ u8 val = 0, lock_sts = 0, link_sts = 0;
int timeout = priv->timeout;
- char timeout_str[10];
+ char timeout_str[40];
int ret = 0;
/* Reverse channel enable */
@@ -340,8 +344,8 @@ static int max9286_reverse_channel_setup(struct i2c_client *client, int idx)
break;
}
- if (timeout == priv->timeout / 2 && poc_trig) {
- if (!IS_ERR(priv->poc_gpio[idx])) {
+ if (poc_trig) {
+ if (!IS_ERR(priv->poc_gpio[idx]) && (timeout % poc_trig == 0)) {
gpiod_direction_output(priv->poc_gpio[idx], 0); /* POC power off */
mdelay(200);
gpiod_direction_output(priv->poc_gpio[idx], 1); /* POC power on */
@@ -352,6 +356,10 @@ static int max9286_reverse_channel_setup(struct i2c_client *client, int idx)
max9286_sensor_reset(client, client->addr, 1); /* sensor reset */
+ client->addr = priv->des_addr; /* MAX9286-CAMx I2C */
+ reg8_read(client, 0x27, &lock_sts); /* LOCK status */
+ reg8_read(client, 0x49, &link_sts); /* LINK status */
+
if (!timeout) {
ret = -ETIMEDOUT;
goto out;
@@ -362,11 +370,11 @@ static int max9286_reverse_channel_setup(struct i2c_client *client, int idx)
priv->csi2_outord |= ((hweight8(priv->links_mask) - 1) << (idx * 2));
out:
- sprintf(timeout_str, "retries=%d", priv->timeout - timeout);
+ sprintf(timeout_str, "retries=%d lock_sts=%d link_sts=0x%x", priv->timeout - timeout, !!(lock_sts & 0x80), link_sts & (0x11 << idx));
dev_info(&client->dev, "link%d %s %sat 0x%x %s %s\n", idx, ser_name(priv->ser_id),
ret == -EADDRINUSE ? "already " : "", priv->max9271_addr_map[idx],
ret == -ETIMEDOUT ? "not found: timeout GMSL link establish" : "",
- priv->timeout - timeout? timeout_str : "");
+ priv->timeout - timeout ? timeout_str : "");
return ret;
}
@@ -741,6 +749,8 @@ static int max9286_parse_dt(struct i2c_client *client)
priv->gpio_resetb = gpio_resetb;
if (active_low_resetb)
priv->active_low_resetb = active_low_resetb;
+ if (timeout_n)
+ priv->timeout = timeout_n;
if (poc_delay)
priv->poc_delay = poc_delay;
if (bws)
--
2.7.4
|