Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5881727pxb; Tue, 16 Feb 2021 09:47:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOLQQNfWHdnwPMRdAlfH/iw4Wuk8xCS8iARtqy6LCNl+dzpDe5sT4IDUuSgTXYzVqYjrDX X-Received: by 2002:aa7:d6d7:: with SMTP id x23mr15468941edr.73.1613497635656; Tue, 16 Feb 2021 09:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613497635; cv=none; d=google.com; s=arc-20160816; b=ajb6JLJppn9hCMXXQ6ZRhWW0R0ip2PinTqyvIzfu1q6NgjJ6dP0lw/t8vtuirCDtaq /OUs5Qq9KQGnAk6GVHgE3e3vWYn4eq1OqrKuCu+JdafCE2/HV3btNYR/DEkhG/JDkiEg SCgDxrSihswHvJ8AZMOSpMo8pKPPOxzIJgMZyTdgCmkvy2WtJkArBH8GvWRpiep3NPkO +EZz4HlAWK6E6afsUHSGguC9QXwFRV/zTt5aM3shRN4VDLhBDizdiA71ieKjdPqQYUkV o/Ac2dWjrp+ALBk26udiXoiBr3mQT+xNu04T0bsVeO5GtOkR0RNCdIjLeLUX/zsBDwyV zwww== 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=Cb41VzntPcekJx2qkHyfVY+hpfOEIW3TnjRR+4rOGXs=; b=O1TnPqfoepMOGvMldZsEjlgSYjIftZ1OVFqMsrSeBJggns5AcK014mL3iK777tU6mx XaUcekJlBWNzBeiU1UDiF6eJp2qGATRoepj+wcdtfmUve9U8VhLzFxQZ6sJTENjS9pL+ ZCuBZbHHBRUm6FEt09xcHpaSB1AcbuCne7Dy9Rkf8xD6adOLKCUxOYcm39NsTh9Of0A8 dcUWnZJMwGBUOPvqWq02vzm9rpU63BUhNJ8fJEUKkkiLvHCE9/vz26ka93n5fkBle/mc UNkgFptcvMsz+B2FICORsK9J9g6ckqGmKjJ1w9yGy5bJIPiiTT6iJJRtQPMg9x/nDSTR KnTg== 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 g9si3613950edm.60.2021.02.16.09.46.52; Tue, 16 Feb 2021 09:47:15 -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 S231157AbhBPRpY (ORCPT + 99 others); Tue, 16 Feb 2021 12:45:24 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:48645 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231145AbhBPRm5 (ORCPT ); Tue, 16 Feb 2021 12:42:57 -0500 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id E2FCC200019; Tue, 16 Feb 2021 17:41:49 +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 , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/16] media: i2c: rdacm2x: Implement .init() subdev op Date: Tue, 16 Feb 2021 18:41:43 +0100 Message-Id: <20210216174146.106639-14-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210216174146.106639-1-jacopo+renesas@jmondi.org> References: <20210216174146.106639-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 The current probe() procedure of the RDACM20 and RDACM20 performs initialization of the serializer image sensors and increases the noise immunity threshold as last operation, which is then compensated by the remote deserializer by increasing the reverse channel signal amplitude once all remotes have bound. The probe routine is then run without noise immunity activated which in noisy environment conditions makes the probe sequence less reliable as the chips configuration requires a relevant amount of i2c transactions. Break chip initialization in two: - At probe time only configure the serializer's reverse channel with noise immunity activated, to reduce the number of transactions performed without noise immunity protection - Move the chips initialization to the .init() core subdev operation to be invoked by the deserializer after the camera has probed and it has increased the reverse channel amplitude Signed-off-by: Jacopo Mondi --- drivers/media/i2c/rdacm20.c | 65 ++++++++++++++++++++++--------------- drivers/media/i2c/rdacm21.c | 65 ++++++++++++++++++++++--------------- 2 files changed, 78 insertions(+), 52 deletions(-) diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c index 39e4b4241870..0632ef98eea7 100644 --- a/drivers/media/i2c/rdacm20.c +++ b/drivers/media/i2c/rdacm20.c @@ -437,36 +437,12 @@ static int rdacm20_get_fmt(struct v4l2_subdev *sd, return 0; } -static const struct v4l2_subdev_video_ops rdacm20_video_ops = { - .s_stream = rdacm20_s_stream, -}; - -static const struct v4l2_subdev_pad_ops rdacm20_subdev_pad_ops = { - .enum_mbus_code = rdacm20_enum_mbus_code, - .get_fmt = rdacm20_get_fmt, - .set_fmt = rdacm20_get_fmt, -}; - -static const struct v4l2_subdev_ops rdacm20_subdev_ops = { - .video = &rdacm20_video_ops, - .pad = &rdacm20_subdev_pad_ops, -}; - -static int rdacm20_initialize(struct rdacm20_device *dev) +static int rdacm20_init(struct v4l2_subdev *sd, unsigned int val) { + struct rdacm20_device *dev = sd_to_rdacm20(sd); unsigned int i; int ret; - /* Verify communication with the MAX9271: ping to wakeup. */ - dev->serializer.client->addr = MAX9271_DEFAULT_ADDR; - i2c_smbus_read_byte(dev->serializer.client); - usleep_range(5000, 8000); - - /* Serial link disabled during config as it needs a valid pixel clock. */ - ret = max9271_set_serial_link(&dev->serializer, false); - if (ret) - return ret; - /* * Ensure that we have a good link configuration before attempting to * identify the device. @@ -537,6 +513,43 @@ static int rdacm20_initialize(struct rdacm20_device *dev) dev_info(dev->dev, "Identified RDACM20 camera module\n"); + return 0; +} + +static const struct v4l2_subdev_core_ops rdacm20_core_ops = { + .init = rdacm20_init, +}; + +static const struct v4l2_subdev_video_ops rdacm20_video_ops = { + .s_stream = rdacm20_s_stream, +}; + +static const struct v4l2_subdev_pad_ops rdacm20_subdev_pad_ops = { + .enum_mbus_code = rdacm20_enum_mbus_code, + .get_fmt = rdacm20_get_fmt, + .set_fmt = rdacm20_get_fmt, +}; + +static const struct v4l2_subdev_ops rdacm20_subdev_ops = { + .core = &rdacm20_core_ops, + .video = &rdacm20_video_ops, + .pad = &rdacm20_subdev_pad_ops, +}; + +static int rdacm20_initialize(struct rdacm20_device *dev) +{ + int ret; + + /* Verify communication with the MAX9271: ping to wakeup. */ + dev->serializer.client->addr = MAX9271_DEFAULT_ADDR; + i2c_smbus_read_byte(dev->serializer.client); + usleep_range(5000, 8000); + + /* Serial link disabled during config as it needs a valid pixel clock. */ + ret = max9271_set_serial_link(&dev->serializer, false); + if (ret) + return ret; + /* * Set reverse channel high threshold to increase noise immunity. * diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c index c420a6b96879..80b6f16f87a8 100644 --- a/drivers/media/i2c/rdacm21.c +++ b/drivers/media/i2c/rdacm21.c @@ -314,21 +314,6 @@ static int rdacm21_get_fmt(struct v4l2_subdev *sd, return 0; } -static const struct v4l2_subdev_video_ops rdacm21_video_ops = { - .s_stream = rdacm21_s_stream, -}; - -static const struct v4l2_subdev_pad_ops rdacm21_subdev_pad_ops = { - .enum_mbus_code = rdacm21_enum_mbus_code, - .get_fmt = rdacm21_get_fmt, - .set_fmt = rdacm21_get_fmt, -}; - -static const struct v4l2_subdev_ops rdacm21_subdev_ops = { - .video = &rdacm21_video_ops, - .pad = &rdacm21_subdev_pad_ops, -}; - static int ov10640_initialize(struct rdacm21_device *dev) { u8 val; @@ -448,20 +433,11 @@ static int ov490_initialize(struct rdacm21_device *dev) return 0; } -static int rdacm21_initialize(struct rdacm21_device *dev) +static int rdacm21_init(struct v4l2_subdev *sd, unsigned int val) { + struct rdacm21_device *dev = sd_to_rdacm21(sd); int ret; - /* Verify communication with the MAX9271: ping to wakeup. */ - dev->serializer.client->addr = MAX9271_DEFAULT_ADDR; - i2c_smbus_read_byte(dev->serializer.client); - usleep_range(5000, 8000); - - /* Enable reverse channel and disable the serial link. */ - ret = max9271_set_serial_link(&dev->serializer, false); - if (ret) - return ret; - /* Configure I2C bus at 105Kbps speed and configure GMSL. */ ret = max9271_configure_i2c(&dev->serializer, MAX9271_I2CSLVSH_469NS_234NS | @@ -508,6 +484,43 @@ static int rdacm21_initialize(struct rdacm21_device *dev) if (ret) return ret; + return 0; +} + +static const struct v4l2_subdev_core_ops rdacm21_core_ops = { + .init = rdacm21_init, +}; + +static const struct v4l2_subdev_video_ops rdacm21_video_ops = { + .s_stream = rdacm21_s_stream, +}; + +static const struct v4l2_subdev_pad_ops rdacm21_subdev_pad_ops = { + .enum_mbus_code = rdacm21_enum_mbus_code, + .get_fmt = rdacm21_get_fmt, + .set_fmt = rdacm21_get_fmt, +}; + +static const struct v4l2_subdev_ops rdacm21_subdev_ops = { + .core = &rdacm21_core_ops, + .video = &rdacm21_video_ops, + .pad = &rdacm21_subdev_pad_ops, +}; + +static int rdacm21_initialize(struct rdacm21_device *dev) +{ + int ret; + + /* Verify communication with the MAX9271: ping to wakeup. */ + dev->serializer.client->addr = MAX9271_DEFAULT_ADDR; + i2c_smbus_read_byte(dev->serializer.client); + usleep_range(5000, 8000); + + /* Enable reverse channel and disable the serial link. */ + ret = max9271_set_serial_link(&dev->serializer, false); + if (ret) + return ret; + /* * Set reverse channel high threshold to increase noise immunity. * -- 2.30.0