Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp423705pxb; Thu, 14 Jan 2021 09:07:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW4DWHGvrzD0egDao7lWNimAK7uLiSepkuDG6B9CeRPkTovyGgtdnEw0WgthIP/hGMLnI0 X-Received: by 2002:a17:906:718b:: with SMTP id h11mr5911934ejk.241.1610644031568; Thu, 14 Jan 2021 09:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610644031; cv=none; d=google.com; s=arc-20160816; b=cs/NX3E27UGC8hoUcThDPmPiXMQ3vvYRpxEV5XfviZSFp+S1fCFzZubbuD0V/MjQ5Z VTIqFn+0yCPpivG1vs+7W0g/g2c9clX8yu0mAs2y95QWkrVHaCeFeesLjR8NsPG4cew9 wMQt9AkFmnldZkkzzk1fdyntDFTcx65+dctEhpzGTu9W5lzfJJk2FfrYB4121KgY3y7e +WnFEf30ZJxQwdfBBNSgm/DskG2eUQXqeYM7ut8mvXSCUw+dcbvGDep5aTSAY2PqbtBY fv9BqkdGVj1kP1Pgn4ybtePqaBWM/8MZsAkkZV0K8Tu6jZLqztQCdBkF65QHPibynhKr hUAw== 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=pPif89s7JQl/did0jD2Fiv8QOBxX8bw6QASwCZi8u2bk/ta7Sd1X/yTpcY3FfLhQ2V w/Ilh4hoN9lWC8ayRW9iBZ67681QOe6uiD2vSpCLUaDkBC5XTYRDfBOsZGFq9SMNfTMI TVLjlKsMpjytFDuetx9jBpjFMOI07qouu8DZA6MHsPI5dWahFcqLwbNjA8CVmf/L4KC6 R0dEXtBTKdZOihJ/kY3NRJZuv8fq977+h9BARIsv6Prxifw1gRG2GeU0nCCwf+pxtSL+ M1jNNGoQnMeiNIzBYWopY6q4J0oJMOD346mHf46V/vomOPwWUs16arKwsjQVsqt3Bs+l y6XQ== 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 mh22si2627020ejb.506.2021.01.14.09.06.45; Thu, 14 Jan 2021 09:07:11 -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 S1728124AbhANRFa (ORCPT + 99 others); Thu, 14 Jan 2021 12:05:30 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:50871 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbhANRFU (ORCPT ); Thu, 14 Jan 2021 12:05:20 -0500 X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 062E74000B; Thu, 14 Jan 2021 17:04:35 +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 v8 4/5] media: i2c: max9286: Make channel amplitude programmable Date: Thu, 14 Jan 2021 18:04:28 +0100 Message-Id: <20210114170429.139762-5-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210114170429.139762-1-jacopo+renesas@jmondi.org> References: <20210114170429.139762-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