[PATCH 5/5] media: i2c: max9286: Parse channel amplitude

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Parse the 'maxim,reverse-channel-amplitude' property value and cache its
content to later program the initial reverse channel amplitude.

Only support 100mV and 170mV values for the moment. The property could
be easily expanded to support more values.

Signed-off-by: Jacopo Mondi <jacopo+renesas@xxxxxxxxxx>
---
 drivers/media/i2c/max9286.c | 39 ++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index 0357515860b2..24af8002535e 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -168,6 +168,7 @@ struct max9286_priv {
 	struct max9286_source sources[MAX9286_NUM_GMSL];
 	struct v4l2_async_notifier notifier;
 
+	u32 reverse_chan_amp;
 	u32 overlap_window;
 };
 
@@ -479,10 +480,15 @@ static int max9286_notify_bound(struct v4l2_async_notifier *notifier,
 	 * All enabled sources have probed and enabled their reverse control
 	 * channels:
 	 *
-	 * - Verify all configuration links are properly detected
+	 * - Increase reverse channel amplitude to 170mV if not initially
+	 *   compensated
 	 * - Disable auto-ack as communication on the control channel are now
 	 *   stable.
 	 */
+	if (priv->reverse_chan_amp == 100)
+		max9286_write(priv, 0x3b, MAX9286_REV_TRF(1) |
+			      MAX9286_REV_AMP(70) | MAX9286_REV_AMP_X);
+
 	max9286_check_config_link(priv, priv->source_mask);
 
 	/*
@@ -830,6 +836,8 @@ static void max9286_v4l2_unregister(struct max9286_priv *priv)
 
 static int max9286_setup(struct max9286_priv *priv)
 {
+	u8 chan_amp = MAX9286_REV_TRF(1);
+
 	/*
 	 * Link ordering values for all enabled links combinations. Orders must
 	 * be assigned sequentially from 0 to the number of enabled links
@@ -869,12 +877,18 @@ static int max9286_setup(struct max9286_priv *priv)
 	 *
 	 * - Enable custom reverse channel configuration (through register 0x3f)
 	 *   and set the first pulse length to 35 clock cycles.
-	 * - Increase the reverse channel amplitude to 170mV to accommodate the
-	 *   high threshold enabled by the serializer driver.
+	 * - Set initial reverse channel amplitude according the DTS property.
+	 *   If the initial channel amplitude is 100mV it should be increase
+	 *   later after the serializers high threshold have been enabled.
+	 *   If the initial value is 170mV the serializer has been
+	 *   pre-programmed and we can compensate immediately.
 	 */
 	max9286_write(priv, 0x3f, MAX9286_EN_REV_CFG | MAX9286_REV_FLEN(35));
-	max9286_write(priv, 0x3b, MAX9286_REV_TRF(1) | MAX9286_REV_AMP(70) |
-		      MAX9286_REV_AMP_X);
+	if (priv->reverse_chan_amp == 100)
+		chan_amp |= MAX9286_REV_AMP(100);
+	else
+		chan_amp |= MAX9286_REV_AMP(70) | MAX9286_REV_AMP_X;
+	max9286_write(priv, 0x3b, chan_amp);
 	usleep_range(2000, 2500);
 
 	/*
@@ -1069,6 +1083,21 @@ static int max9286_parse_dt(struct max9286_priv *priv)
 		return -EINVAL;
 	}
 
+	ret = of_property_read_u32(dev->of_node, "maxim,reverse-channel-amplitude",
+				   &priv->reverse_chan_amp);
+	if (ret) {
+		dev_err(dev,
+			"Missing property \"maxim,reverse-channel-amplitude\"\n");
+		of_node_put(dev->of_node);
+		return -EINVAL;
+	}
+	if (priv->reverse_chan_amp != 100 && priv->reverse_chan_amp != 170) {
+		dev_err(dev, "Unsupported  channel amplitude %umV\n",
+			priv->reverse_chan_amp);
+		of_node_put(dev->of_node);
+		return -EINVAL;
+	}
+
 	i2c_mux = of_find_node_by_name(dev->of_node, "i2c-mux");
 	if (!i2c_mux) {
 		dev_err(dev, "Failed to find i2c-mux node\n");
-- 
2.25.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux