Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2152064pxa; Mon, 3 Aug 2020 08:43:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr0/4uhgeZu3SKykJ+tDsL2SxlyRsK6UCBJ9XymPXJHg2d3agTfIFMveMPdNzmIdu6mlx1 X-Received: by 2002:a50:d784:: with SMTP id w4mr16660696edi.34.1596469417459; Mon, 03 Aug 2020 08:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596469417; cv=none; d=google.com; s=arc-20160816; b=osm5+WuWlWr43jm6kZquW2T78/xOz7CKocSM5BK5TlQXMIsi5RhJ1uQQqAOz8o0TgB VGNGMgkp77RRD+Pm0phdA+6w/8TtoFV2e179GjEcF+j4CPOI/5TqVfYI7UJxixkE3ADs i4aq0aLMBq0KM+1wKuvXgG8UO6w6xd7ReoGybecUA1+DcqCVVKUujneYQghM/8BaYo7e Y9Xl9M9vXme8VTiq8mhmKCiPbzZ7te4hT16qAfhV30onXSMTbzVZ/VfEdS7l13YFgZcq FXxnBRB6CjaJVdWR6kR0sP8cz0/jgZKCtIx5W2DM7uFFOAEvpjPM1lbY3HtXRJf7ypM3 Qj3w== 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=wDgMkeYCZVezNoEVbmypSzb8rMjS8a+LjilsX0gytzo=; b=yAY8B1ca3/jDehp6N/+wSefp5e1o+L09V3ohJr5AObfxc1OSBbGNSjkXvQOW8nfy3f 7BTWuZJ5MHtP9np6FCBtPNE7Gti1Or1Mje6TRbkWH41uxb+Nz/81MELvpUj/MWnIgxVA 2tTDEhRASxYOsUumCbpeY+YF+uIU9lLm1/8RAAfrHcnAti6lZybd87tYV5cfcgONSNUx tikJvKjRZ4oBPCABkxhPAV+qPY3ML/iwbOiARWHwLL+qEx5cN8qCm/cmgY+EEKtN1Gty Txsd6Ea1GKYqps5RpE2Yr+sU/brgi6TbuEUo4Gt9FDoocdZ2VFEHpT/mcY79CPBmrAM6 cWXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=BCZv90eb; 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 a3si11097449ejd.449.2020.08.03.08.43.15; Mon, 03 Aug 2020 08:43:37 -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=BCZv90eb; 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 S1728117AbgHCPmj (ORCPT + 99 others); Mon, 3 Aug 2020 11:42:39 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:16623 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728048AbgHCPmg (ORCPT ); Mon, 3 Aug 2020 11:42:36 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 03 Aug 2020 08:40:58 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 03 Aug 2020 08:42:35 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 03 Aug 2020 08:42:35 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 3 Aug 2020 15:42:35 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 3 Aug 2020 15:42:35 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.167.221]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 03 Aug 2020 08:42:35 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , Subject: [PATCH v8 08/10] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done Date: Mon, 3 Aug 2020 08:42:24 -0700 Message-ID: <1596469346-937-9-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596469346-937-1-git-send-email-skomatineni@nvidia.com> References: <1596469346-937-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=1596469258; bh=wDgMkeYCZVezNoEVbmypSzb8rMjS8a+LjilsX0gytzo=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=BCZv90ebln0SePLIs+xmu+/ZB3CvdH6PELpJPaiqOwnRkfao3sAU30ciwSUR7F6J3 In2biTD5EY8e0nNnYBtgDMHM/qntlS18P002arns6LGrMZRvSqB4pw8PlhxSQKPoj7 5Ol057x14GJVww2MnkdnfLgBpTN1ZBI8fKVvQYsmWexWV9SBIlRqxzZYX63am9KGkE GR2H2KL5GNqM4F7bNYYLbVKB1fmBCAcgJKJKE7wcaam3208XEt6XG2JmJEk0zJJMEu Ot1F6Vxhq6dmnAobIxOeISWLH+eYtd4WAl5hTSvQqeEH0ArqSs0j8byuOxwaCRabKh pBPZ7bRIGp9+Q== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the split of MIPI calibration into tegra_mipi_calibrate() and tegra_mipi_wait(), MIPI clock is not kept enabled till the calibration is done. So, this patch skips disabling MIPI clock after triggering start of calibration and disables it only after waiting for done status from the calibration logic. This patch renames tegra_mipi_calibrate() as tegra_mipi_start_calibration() and tegra_mipi_wait() as tegra_mipi_finish_calibration() to be inline with their usage. As MIPI clock is left enabled and in case of any failures with CSI input streaming tegra_mipi_finish_calibration() will not get invoked. So added new API tegra_mipi_cancel_calibration() which disables MIPI clock and consumer drivers can call this in such cases. Reviewed-by: Dmitry Osipenko Signed-off-by: Sowjanya Komatineni --- drivers/gpu/drm/tegra/dsi.c | 4 ++-- drivers/gpu/host1x/mipi.c | 19 ++++++++++--------- include/linux/host1x.h | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index 3820e8d..a7864e9 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c @@ -694,11 +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); - err = tegra_mipi_calibrate(dsi->mipi); + err = tegra_mipi_start_calibration(dsi->mipi); if (err < 0) return err; - return tegra_mipi_wait(dsi->mipi); + return tegra_mipi_finish_calibration(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 e606464..b15ab6e 100644 --- a/drivers/gpu/host1x/mipi.c +++ b/drivers/gpu/host1x/mipi.c @@ -293,17 +293,19 @@ int tegra_mipi_disable(struct tegra_mipi_device *dev) } EXPORT_SYMBOL(tegra_mipi_disable); -int tegra_mipi_wait(struct tegra_mipi_device *device) +void tegra_mipi_cancel_calibration(struct tegra_mipi_device *device) +{ + clk_disable(device->mipi->clk); +} +EXPORT_SYMBOL(tegra_mipi_cancel_calibration); + +int tegra_mipi_finish_calibration(struct tegra_mipi_device *device) { struct tegra_mipi *mipi = device->mipi; void __iomem *status_reg = mipi->regs + (MIPI_CAL_STATUS << 2); u32 value; int err; - err = clk_enable(device->mipi->clk); - if (err < 0) - return err; - mutex_lock(&device->mipi->lock); err = readl_relaxed_poll_timeout(status_reg, value, @@ -315,9 +317,9 @@ int tegra_mipi_wait(struct tegra_mipi_device *device) return err; } -EXPORT_SYMBOL(tegra_mipi_wait); +EXPORT_SYMBOL(tegra_mipi_finish_calibration); -int tegra_mipi_calibrate(struct tegra_mipi_device *device) +int tegra_mipi_start_calibration(struct tegra_mipi_device *device) { const struct tegra_mipi_soc *soc = device->mipi->soc; unsigned int i; @@ -382,11 +384,10 @@ int tegra_mipi_calibrate(struct tegra_mipi_device *device) tegra_mipi_writel(device->mipi, value, MIPI_CAL_CTRL); mutex_unlock(&device->mipi->lock); - clk_disable(device->mipi->clk); return 0; } -EXPORT_SYMBOL(tegra_mipi_calibrate); +EXPORT_SYMBOL(tegra_mipi_start_calibration); static const struct tegra_mipi_pad tegra114_mipi_pads[] = { { .data = MIPI_CAL_CONFIG_CSIA }, diff --git a/include/linux/host1x.h b/include/linux/host1x.h index 20c885d..b490dda 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h @@ -333,7 +333,8 @@ struct tegra_mipi_device *tegra_mipi_request(struct device *device, 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); +int tegra_mipi_start_calibration(struct tegra_mipi_device *device); +int tegra_mipi_finish_calibration(struct tegra_mipi_device *device); +void tegra_mipi_cancel_calibration(struct tegra_mipi_device *device); #endif -- 2.7.4