From patchwork Sun Oct 1 10:22:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Chen X-Patchwork-Id: 9979661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C3C560365 for ; Sun, 1 Oct 2017 10:23:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF5C328A88 for ; Sun, 1 Oct 2017 10:23:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E458128BBF; Sun, 1 Oct 2017 10:23:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A01B28A88 for ; Sun, 1 Oct 2017 10:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750992AbdJAKW4 (ORCPT ); Sun, 1 Oct 2017 06:22:56 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36357 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849AbdJAKWy (ORCPT ); Sun, 1 Oct 2017 06:22:54 -0400 Received: by mail-pg0-f68.google.com with SMTP id d8so2895846pgt.3; Sun, 01 Oct 2017 03:22:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LNRqXgLzv1tvrpnEQp0TeyvWiw4efB8nX41fp659NGc=; b=W/8DiZkjn8twTLqu0QffgVtt3FU91WvilZ12jjqPQRJmAdK7I8E9TwZ6aBIHH4XKus D4tLuqOHp86wpCj+gwS/3Z3EVdtE9GMeMMXWhEsQErGefwJ0WR4m2G5D4excQmOQpXG1 YbdbquOsz9Kw3X0Ub20+XiuaaGOQ+0IyBbUfbuRn+KI+h9MLoSx8hKWydGrmMwMpyOA4 Uj53QqXpZ8rVXkQz6itlv42Il8fzAn0jfApYSg7uB8qa0eDvTrvEnpy3OM7Kl61vsbAu B4tenpiKfhM2cc0nHT+BKYR8kGODV3qpNp/4NAisYcALlRpqsv5YP3w9Zf0k9puR1IzE fYGw== X-Gm-Message-State: AMCzsaUAOFDZPzTGm90VDKbBMafsWtaElA1QMd4ZH3P1QLllmBtG2oG+ 3gGV4lcj/n6qJMnBLhVKAYhllQ== X-Google-Smtp-Source: AOwi7QDw/AGr35LQqxdnUiB//NNSq320JeNw/5r8U01Xs+FZxvKJYSZXfmiCZuf3yXeo3Llgk2OT6A== X-Received: by 10.98.49.3 with SMTP id x3mr1322991pfx.118.1506853374141; Sun, 01 Oct 2017 03:22:54 -0700 (PDT) Received: from localhost.localdomain ([198.199.94.210]) by smtp.gmail.com with ESMTPSA id y7sm12914991pfy.35.2017.10.01.03.22.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Oct 2017 03:22:53 -0700 (PDT) From: Jacob Chen To: linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mchehab@kernel.org, vladimir_zapolskiy@mentor.com, hans.verkuil@cisco.com, sakari.ailus@linux.intel.com, lolivei@synopsys.com, p.zabel@pengutronix.de, Jacob Chen Subject: [PATCH v3 1/2] media: i2c: OV5647: ensure clock lane in LP-11 state before streaming on Date: Sun, 1 Oct 2017 18:22:37 +0800 Message-Id: <20171001102238.21585-1-jacob-chen@iotwrt.com> X-Mailer: git-send-email 2.14.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When I was supporting Rpi Camera Module on the ASUS Tinker board, I found this driver have some issues with rockchip's mipi-csi driver. It didn't place clock lane in LP-11 state before performing D-PHY initialisation. From our experience, on some OV sensors, LP-11 state is not achieved while BIT(5)-0x4800 is cleared. So let's set BIT(5) and BIT(0) both while not streaming, in order to coax the clock lane into LP-11 state. 0x4800 : MIPI CTRL 00 BIT(5) : clock lane gate enable 0: continuous 1: none-continuous BIT(0) : manually set clock lane 0: Not used 1: used Signed-off-by: Jacob Chen Reviewed-by: Luis Oliveira --- drivers/media/i2c/ov5647.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c index 95ce90fdb876..247302d01f53 100644 --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c @@ -253,6 +253,10 @@ static int ov5647_stream_on(struct v4l2_subdev *sd) { int ret; + ret = ov5647_write(sd, 0x4800, 0x04); + if (ret < 0) + return ret; + ret = ov5647_write(sd, 0x4202, 0x00); if (ret < 0) return ret; @@ -264,6 +268,10 @@ static int ov5647_stream_off(struct v4l2_subdev *sd) { int ret; + ret = ov5647_write(sd, 0x4800, 0x25); + if (ret < 0) + return ret; + ret = ov5647_write(sd, 0x4202, 0x0f); if (ret < 0) return ret; @@ -320,7 +328,10 @@ static int __sensor_init(struct v4l2_subdev *sd) return ret; } - return ov5647_write(sd, 0x4800, 0x04); + /* + * stream off to make the clock lane into LP-11 state. + */ + return ov5647_stream_off(sd); } static int ov5647_sensor_power(struct v4l2_subdev *sd, int on)