Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp251840ybg; Tue, 9 Jun 2020 23:06:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrkLA8KuQLmU5fMm9hCkv094SzWg0epZEsGpXAGZnSqMMfjSmqXZhZiEprTVosM5Qc4Twx X-Received: by 2002:a17:906:b7cd:: with SMTP id fy13mr1878737ejb.133.1591769183252; Tue, 09 Jun 2020 23:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591769183; cv=none; d=google.com; s=arc-20160816; b=0vjNXlEKzzh1Ssz1/23SdQGf1bcUWsV1aY0UKpLvipuuNDrq7wRRieuAZdxI28vgfB ouad1EQoqBOnaq+9wSizfmOVAteoWpLgwZiWP6st0Y2a7kvV7NPh3Y27GZa8ikXeBlDb Usepb3eyDAE9CzGHAgYBN4yRQsvRwCaTaPB8vOg3Zj5NbodldGeXSTVD8rnY1ZZUv3np phAK2y5U8PIDkVxx78oLXh6bLRe1XxMV+HSiwMOLV/V0acEexg6QKJYno8yWcx8DoO3w DUi2166nLgJjwH9VyuYfQ90wE5KmmZP58z29+/hFWxLZJiaF9qaMKsSfQ/dnnXV4vRZs j4Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=4ES5kAI2PqYLOuW0Im9Hz1dnAeW5Q4i+H7tHmdv9tVo=; b=OuWozVdgzSbz+xaRCeUdTPVc5z2VxVSSF4MByiEXU5FUUJFQsK/PkMTj0IuLQFz0oN mo+Ts1m8ua6uPvdz/tPsmDrwWI/5eWaeYGYocBEf61llQR4zsLaEPsIhzYvUGB13UDbb xe2jUxCF2LvPGYdYaqqRQQkijp8intRjzpCXBUzNu0C/wpeiL01LbFqewfkGMlrEhEma ZbO9us0062ZEJYr0vczdXs7+xRuRNSq3xOCZtGD9DOQ8pwcDksWzBYEfPWRyUkeT12n4 0QPhY6s1SRA+VO+sdvmZOwByHLFqja0h6HqT42SM8os9zPvNjqDDAW3TuTfzycern5Hh XFvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=E037ThJS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si11783422ejs.182.2020.06.09.23.05.57; Tue, 09 Jun 2020 23:06:23 -0700 (PDT) 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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=E037ThJS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726424AbgFJGDk (ORCPT + 99 others); Wed, 10 Jun 2020 02:03:40 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:11247 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbgFJGCy (ORCPT ); Wed, 10 Jun 2020 02:02:54 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 09 Jun 2020 23:01:21 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 09 Jun 2020 23:02:52 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 09 Jun 2020 23:02:52 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 10 Jun 2020 06:02:52 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 10 Jun 2020 06:02:52 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.167.70]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 09 Jun 2020 23:02:51 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , Subject: [RFC PATCH v1 14/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait Date: Tue, 9 Jun 2020 23:02:36 -0700 Message-ID: <1591768960-31648-15-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591768960-31648-1-git-send-email-skomatineni@nvidia.com> References: <1591768960-31648-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1591768881; bh=4ES5kAI2PqYLOuW0Im9Hz1dnAeW5Q4i+H7tHmdv9tVo=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=E037ThJS7qicWEsMWvyN/ueFgwG4zQpBEo07RuddWKJ32kyJJ0rkb2WGoa1D9Xx3S aYYnrbQ5C3DxvzcEaK4o8IYsP9DzAgP6QJj/0vu7gSL1dLGv407/4ZYwYTsyG0uQz4 KWf+mdaWYqJ8JnvHIglMdYixDisYyR/XF986yG8HRzjkptct4cZ7L9uPeadAPGzPvV yIshu15lKPipChUSrC7cu30GqO9SsPAFoUNScf4gNuRWAw4GzXwPgmNAtu9fl8Qy5q JPtccvmr/83nkDj1GZOYRu0Dbig07SfMBAZWQKqvaDcF8hdmf+vZ4uzDx4ZqNwROSf k12s7xbWpFdIA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SW can trigger MIPI pads calibration any time after power on but calibration results will be latched and applied to the pads by MIPI CAL unit only when the link is in LP-11 state and then status register will be updated. For CSI, trigger of pads calibration happen during CSI stream enable where CSI receiver is kept ready prior to sensor or CSI transmitter stream start. So, pads may not be in LP-11 at this time and waiting for the calibration to be done immediate after calibration start will result in timeout. This patch splits tegra_mipi_calibrate() and tegra_mipi_wait() so triggering for calibration and waiting for it to complete can happen at different stages. Signed-off-by: Sowjanya Komatineni --- drivers/gpu/drm/tegra/dsi.c | 7 ++++++- drivers/gpu/host1x/mipi.c | 23 +++++++++++++++++------ include/linux/host1x.h | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index 38beab9..814363f 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c @@ -670,6 +670,7 @@ static int tegra_dsi_pad_enable(struct tegra_dsi *dsi) static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) { u32 value; + int ret; /* * XXX Is this still needed? The module reset is deasserted right @@ -693,7 +694,11 @@ static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); - return tegra_mipi_calibrate(dsi->mipi); + ret = tegra_mipi_calibrate(dsi->mipi); + if (ret < 0) + return ret; + + return tegra_mipi_wait(dsi->mipi); } static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk, diff --git a/drivers/gpu/host1x/mipi.c b/drivers/gpu/host1x/mipi.c index f51fe69..a01df6a 100644 --- a/drivers/gpu/host1x/mipi.c +++ b/drivers/gpu/host1x/mipi.c @@ -299,22 +299,35 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -static int tegra_mipi_wait(struct tegra_mipi *mipi) +int tegra_mipi_wait(struct tegra_mipi_device *device) { + struct tegra_mipi *mipi = device->mipi; unsigned long timeout = jiffies + msecs_to_jiffies(250); u32 value; + int err; + + err = clk_enable(device->mipi->clk); + if (err < 0) + return err; + + mutex_lock(&device->mipi->lock); while (time_before(jiffies, timeout)) { value = tegra_mipi_readl(mipi, MIPI_CAL_STATUS); if ((value & MIPI_CAL_STATUS_ACTIVE) == 0 && (value & MIPI_CAL_STATUS_DONE) != 0) - return 0; + goto done; usleep_range(10, 50); } - return -ETIMEDOUT; + err = -ETIMEDOUT; +done: + mutex_unlock(&device->mipi->lock); + clk_disable(device->mipi->clk); + return err; } +EXPORT_SYMBOL(tegra_mipi_wait); int tegra_mipi_calibrate(struct tegra_mipi_device *device) { @@ -380,12 +393,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device) value |= MIPI_CAL_CTRL_START; tegra_mipi_writel(device->mipi, value, MIPI_CAL_CTRL); - err = tegra_mipi_wait(device->mipi); - mutex_unlock(&device->mipi->lock); clk_disable(device->mipi->clk); - return err; + return 0; } EXPORT_SYMBOL(tegra_mipi_calibrate); diff --git a/include/linux/host1x.h b/include/linux/host1x.h index a61ca52..dbad062 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h @@ -332,5 +332,6 @@ void tegra_mipi_free(struct tegra_mipi_device *device); int tegra_mipi_enable(struct tegra_mipi_device *device); int tegra_mipi_disable(struct tegra_mipi_device *device); int tegra_mipi_calibrate(struct tegra_mipi_device *device); +int tegra_mipi_wait(struct tegra_mipi_device *device); #endif -- 2.7.4