Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp593592pxb; Wed, 13 Jan 2021 10:58:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCJlOrebusTazn3HJ5RRDIz7qY3Lc+nKF28ZrqOVlWkI9pRN2N8ejqDs6/LJXy8/Jg2+wr X-Received: by 2002:a17:906:1288:: with SMTP id k8mr2564976ejb.206.1610564296892; Wed, 13 Jan 2021 10:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610564296; cv=none; d=google.com; s=arc-20160816; b=kBm44sSp3tN86upBcItZ2q1XE21IdfhogFVY/l+DIlix+zUggE5Jsw2sJcqknny8IJ wVv28XtRoV+AFA9B0B6jifIvK9174WNAz4QwSu3l0CSmOPfSMk0PrkSudvNgnow046B1 pr1afm3ekdZonXeUnnHpJTzKpIueStUaZErQlrIdJRaNmkisQMch4sxLZjEVvAKP1MfP 83GU2HJx/a32PhjfT/5I0vv9mVCst+QE7eXQdNNDtiF5kUG+j6icEzt1PKp0vc4yK0jI ZbueKaxdZaPnB7u05N98QgzV3mDLsbfm1nWBAM4qZ9CltmQRtrd0e/zykTADVxd6QQQ0 WS4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9sk944nFMo+9XY7P1wcracXtAD4byefLKqP1CkpVOEQ=; b=FAPI28HNiXojpBSqgLTUHakE6yqW+X55tafBqvLrjGWryFM35cnCN3ckjKIJqDRaCV HeYWUoFpeNIgg21B6p3tcchWHcmO9NAnY1oryk8GVfi5B6s2xJHyOXrGE079t5DY1RG1 aqbuL6XsLCU++Bw5bh/YPwC1CdTanU+wLhxztTxT4noG44BGUWaShG8WrngGf29lH33W +8+naVwZ3FLwG8JIgGMh2VQtY7oJJ7E4VtXT3OozT9VyTuEBU+H8quyV75c/F6qYCEax A6XgGl8SUDOXWFpKQG8st2VUEBSusc7hDC76geX0jWO08/ikE02KlfbQNx0+if2d4RTq EoKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si1271749ejv.428.2021.01.13.10.57.53; Wed, 13 Jan 2021 10:58:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728640AbhAMSzz (ORCPT + 99 others); Wed, 13 Jan 2021 13:55:55 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:36921 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728552AbhAMSzz (ORCPT ); Wed, 13 Jan 2021 13:55:55 -0500 X-Originating-IP: 93.61.96.190 Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 210711C0013; Wed, 13 Jan 2021 18:55:10 +0000 (UTC) From: Jacopo Mondi To: kieran.bingham+renesas@ideasonboard.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, geert@linux-m68k.org Cc: Jacopo Mondi , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Hyun Kwon , Manivannan Sadhasivam , sergei.shtylyov@gmail.com, Laurent Pinchart Subject: [PATCH v7 6/7] media: i2c: max9286: Make channel amplitude programmable Date: Wed, 13 Jan 2021 19:55:04 +0100 Message-Id: <20210113185506.119808-7-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210113185506.119808-1-jacopo+renesas@jmondi.org> References: <20210113185506.119808-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instrument the function that configures the reverse channel with a programmable amplitude value. This change serves to prepare to adjust the reverse channel amplitude depending on the remote end high-threshold configuration. Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi --- drivers/media/i2c/max9286.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 1cfc8801c0b2..ba84a2d7e29b 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -336,19 +336,28 @@ static void max9286_configure_i2c(struct max9286_priv *priv, bool localack) usleep_range(3000, 5000); } -static void max9286_reverse_channel_setup(struct max9286_priv *priv) +static void max9286_reverse_channel_setup(struct max9286_priv *priv, + unsigned int chan_amplitude) { + /* Reverse channel transmission time: default to 1. */ + u8 chan_config = MAX9286_REV_TRF(1); + /* * Reverse channel setup. * * - 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. + * - Adjust reverse channel amplitude: values > 130 are programmed + * using the additional +100mV REV_AMP_X boost flag */ 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 (chan_amplitude > 100) { + /* It is not possible to express values (100 < x < 130) */ + chan_amplitude = max(30U, chan_amplitude - 100); + chan_config |= MAX9286_REV_AMP_X; + } + max9286_write(priv, 0x3b, chan_config | MAX9286_REV_AMP(chan_amplitude)); usleep_range(2000, 2500); } @@ -957,7 +966,7 @@ static int max9286_setup(struct max9286_priv *priv) * only. This should be disabled after the mux is initialised. */ max9286_configure_i2c(priv, true); - max9286_reverse_channel_setup(priv); + max9286_reverse_channel_setup(priv, 170); /* * Enable GMSL links, mask unused ones and autodetect link -- 2.29.2