linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo+renesas@jmondi.org>
To: kieran.bingham+renesas@ideasonboard.com,
	laurent.pinchart@ideasonboard.com, niklas.soderlund@ragnatech.se
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	linux-renesas-soc@vger.kernel.org
Subject: [RFC 08/11] media: i2c: max9286: Move link setup to completion
Date: Mon, 16 Dec 2019 18:16:17 +0100	[thread overview]
Message-ID: <20191216171620.372683-9-jacopo+renesas@jmondi.org> (raw)
In-Reply-To: <20191216171620.372683-1-jacopo+renesas@jmondi.org>

The max9286 async notifier is a sub-notifier which does not support a
'complete' callback.

In order to properly complete the reverse channel configuration, we need
to perform operations after all remote serializers have completed their
probe.

Keep track of how many serializers have probed, and once all the
expected ones have completed its initialization:
1) Compensate the reverse channel high threshold
2) Verify that all expected control links are enabled
3) Disable i2c auto-ack

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/max9286.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index 3c2c1f506983..f75c97ef87a8 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -166,6 +166,7 @@ struct max9286_priv {
 	unsigned int nsources;
 	unsigned int source_mask;
 	unsigned int route_mask;
+	unsigned int bound_sources;
 	unsigned int csi2_data_lanes;
 	struct max9286_source sources[MAX9286_NUM_GMSL];
 	struct v4l2_async_notifier notifier;
@@ -570,6 +571,7 @@ static int max9286_notify_bound(struct v4l2_async_notifier *notifier,
 
 	source->sd = subdev;
 	src_pad = ret;
+	priv->bound_sources |= BIT(index);
 
 	ret = media_create_pad_link(&source->sd->entity, src_pad,
 				    &priv->sd.entity, index,
@@ -585,6 +587,25 @@ static int max9286_notify_bound(struct v4l2_async_notifier *notifier,
 	dev_dbg(&priv->client->dev, "Bound %s pad: %u on index %u\n",
 		subdev->name, src_pad, index);
 
+	if (priv->bound_sources != priv->source_mask)
+		return 0;
+
+	/*
+	 * All enabled sources have probed and enabled their reverse control
+	 * channels:
+	 *
+	 * - Increase the reverse channel amplitude to 170mV to accommodate the
+	 *   high threshold enabled by the serializer driver.
+	 * - Verify all configuration links are properly detected
+	 * - Disable auto-ack as communication on the control channel are now
+	 *   stable.
+	 */
+	max9286_write(priv, 0x3b, MAX9286_REV_TRF(1) | MAX9286_REV_AMP(70) |
+		      MAX9286_REV_AMP_X);
+	usleep_range(2000, 2500);
+	max9286_check_config_link(priv, priv->source_mask);
+	max9286_configure_i2c(priv, false);
+
 	return 0;
 }
 
@@ -876,11 +897,6 @@ static int max9286_setup(struct max9286_priv *priv)
 	 */
 	usleep_range(2000, 5000);
 
-	/*
-	 * Check to see if the expected configuration links are up.
-	 */
-	max9286_check_config_link(priv, priv->source_mask);
-
 	return 0;
 }
 
@@ -1042,12 +1058,6 @@ static int max9286_init(struct device *dev, void *data)
 		goto err_subdev_unregister;
 	}
 
-	/*
-	 * Re-configure I2C with local acknowledge disabled after cameras
-	 * have probed.
-	 */
-	max9286_configure_i2c(priv, false);
-
 	/* Leave the mux channels disabled until they are selected. */
 	max9286_i2c_mux_close(priv);
 
-- 
2.24.0


  parent reply	other threads:[~2019-12-16 17:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 17:16 [RFC 00/11] GMSL: Initial RDACM21 support Jacopo Mondi
2019-12-16 17:16 ` [RFC 01/11] fixup! DNI: Debug Jacopo Mondi
2019-12-16 22:34   ` Kieran Bingham
2019-12-16 17:16 ` [RFC 02/11] fixup! arm64: dts: renesas: salvator-x: Add MAX9286 expansion board Jacopo Mondi
2019-12-16 22:37   ` Kieran Bingham
2019-12-16 17:16 ` [RFC 03/11] fixup! arm64: dts: renesas: eagle: Provide Eagle FAKRA dynamic overlay Jacopo Mondi
2019-12-16 22:40   ` Kieran Bingham
2019-12-16 17:16 ` [RFC 04/11] fixup! arm64: dts: renesas: eagle: Provide MAX9286 GMSL deserialiser Jacopo Mondi
2019-12-16 22:41   ` Kieran Bingham
2019-12-16 17:16 ` [RFC 05/11] fixup! dt-bindings: media: i2c: Add bindings for IMI RDACM20 Jacopo Mondi
2019-12-16 22:42   ` Laurent Pinchart
2020-02-14  9:07     ` Kieran Bingham
2019-12-16 17:16 ` [RFC 06/11] media: i2c: Break out max9271 from rdacm20 driver Jacopo Mondi
2019-12-16 17:16 ` [RFC 07/11] media: i2c: max9286: Move notifiers operations Jacopo Mondi
2019-12-16 17:16 ` Jacopo Mondi [this message]
2019-12-16 17:16 ` [RFC 09/11] media: i2c: max9286: Expand reverse chanenl amplitude Jacopo Mondi
2019-12-16 17:16 ` [RFC 10/11] WIP: media: i2c: rdacm20: Add RDACM21 support Jacopo Mondi
2019-12-16 17:16 ` [RFC 11/11] arm64: boot: dts: Eagle: Enable RDACM21 Jacopo Mondi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191216171620.372683-9-jacopo+renesas@jmondi.org \
    --to=jacopo+renesas@jmondi.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).