From patchwork Tue Dec 6 10:24:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: matrandg@cisco.com X-Patchwork-Id: 9462309 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 16D526022E for ; Tue, 6 Dec 2016 10:39:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 196CF212D7 for ; Tue, 6 Dec 2016 10:39:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E21F27DCD; Tue, 6 Dec 2016 10:39:06 +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=-14.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham 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 68ECC212D7 for ; Tue, 6 Dec 2016 10:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753168AbcLFKix (ORCPT ); Tue, 6 Dec 2016 05:38:53 -0500 Received: from aer-iport-3.cisco.com ([173.38.203.53]:24562 "EHLO aer-iport-3.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752867AbcLFKiv (ORCPT ); Tue, 6 Dec 2016 05:38:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2577; q=dns/txt; s=iport; t=1481020731; x=1482230331; h=from:to:cc:subject:date:message-id; bh=en29wrt6JDQcgjoM6YZawqQ3vwu8Mlgl0gPtUCVnf6I=; b=SkIkfce955jG2eLApZ2mPSuvxT2moJRJslXuHd58qyU8zZl385Qkw1y3 Eru1S2V68ej3mGG31i4+QExIfy7WzHOYrvg5Nf6Ycx8FkaqC1zMeTZzdQ oWqaTSpwRD7AaENEf6qLZ/q1WcMhwU2ls1VYjKDKHCflUcLDo2hhQFHge Q=; X-IronPort-AV: E=Sophos;i="5.33,309,1477958400"; d="scan'208";a="648672812" Received: from aer-iport-nat.cisco.com (HELO aer-core-3.cisco.com) ([173.38.203.22]) by aer-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2016 10:24:36 +0000 Received: from mrapc.rd.cisco.com ([10.47.76.179]) by aer-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id uB6AOaso007704; Tue, 6 Dec 2016 10:24:36 GMT From: matrandg@cisco.com To: linux-media@vger.kernel.org Cc: Mats Randgaard Subject: [PATCH 1/3] tc358743: Do not read number of CSI lanes in use from chip Date: Tue, 6 Dec 2016 11:24:27 +0100 Message-Id: <1481019869-20093-1-git-send-email-matrandg@cisco.com> X-Mailer: git-send-email 2.7.4 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 From: Mats Randgaard The number of CSI lanes that should be used is set to the CSI_CONTROL register by indirectly writing to the CSI_CONFW register. When the number of lanes is read back from the CSI_CONTROL register the value is usually correct, but we have seen that it suddenly is 1 for a short moment before the correct value is restored again. Toshiba have not figured out why that happen, but we have found it safer to store the value in the driver. Signed-off-by: Mats Randgaard --- drivers/media/i2c/tc358743.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 1e3a0dd2..a35aaf8 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -96,6 +96,7 @@ struct tc358743_state { struct v4l2_dv_timings timings; u32 mbus_fmt_code; + u8 csi_lanes_in_use; struct gpio_desc *reset_gpio; }; @@ -287,11 +288,6 @@ static int get_audio_sampling_rate(struct v4l2_subdev *sd) return code_to_rate[i2c_rd8(sd, FS_SET) & MASK_FS]; } -static unsigned tc358743_num_csi_lanes_in_use(struct v4l2_subdev *sd) -{ - return ((i2c_rd32(sd, CSI_CONTROL) & MASK_NOL) >> 1) + 1; -} - /* --------------- TIMINGS --------------- */ static inline unsigned fps(const struct v4l2_bt_timings *t) @@ -683,6 +679,8 @@ static void tc358743_set_csi(struct v4l2_subdev *sd) v4l2_dbg(3, debug, sd, "%s:\n", __func__); + state->csi_lanes_in_use = lanes; + tc358743_reset(sd, MASK_CTXRST); if (lanes < 1) @@ -1155,7 +1153,7 @@ static int tc358743_log_status(struct v4l2_subdev *sd) v4l2_info(sd, "Lanes needed: %d\n", tc358743_num_csi_lanes_needed(sd)); v4l2_info(sd, "Lanes in use: %d\n", - tc358743_num_csi_lanes_in_use(sd)); + state->csi_lanes_in_use); v4l2_info(sd, "Waiting for particular sync signal: %s\n", (i2c_rd16(sd, CSI_STATUS) & MASK_S_WSYNC) ? "yes" : "no"); @@ -1438,12 +1436,14 @@ static int tc358743_dv_timings_cap(struct v4l2_subdev *sd, static int tc358743_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { + struct tc358743_state *state = to_state(sd); + cfg->type = V4L2_MBUS_CSI2; /* Support for non-continuous CSI-2 clock is missing in the driver */ cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; - switch (tc358743_num_csi_lanes_in_use(sd)) { + switch (state->csi_lanes_in_use) { case 1: cfg->flags |= V4L2_MBUS_CSI2_1_LANE; break;