Linux-Tegra Archive on lore.kernel.org
 help / color / Atom feed
From: Sowjanya Komatineni <skomatineni@nvidia.com>
To: Dmitry Osipenko <digetx@gmail.com>, <thierry.reding@gmail.com>,
	<jonathanh@nvidia.com>, <frankc@nvidia.com>, <hverkuil@xs4all.nl>,
	<sakari.ailus@iki.fi>, <robh+dt@kernel.org>,
	<helen.koike@collabora.com>
Cc: <sboyd@kernel.org>, <gregkh@linuxfoundation.org>,
	<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-i2c@vger.kernel.org>
Subject: Re: [RFC PATCH v5 12/14] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done
Date: Tue, 28 Jul 2020 09:04:32 -0700
Message-ID: <69903c67-8e5f-11c2-45ec-c76b97634aba@nvidia.com> (raw)
In-Reply-To: <b21e3227-d0d8-5b4a-ae69-aa29551a22c3@gmail.com>


On 7/28/20 4:03 AM, Dmitry Osipenko wrote:
> 27.07.2020 23:57, Sowjanya Komatineni пишет:
>> 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.
>>
>> Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com>
>> ---
>>   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)
>> +{
> Doesn't MIPI_CAL need to be reset here?
No need to reset MIPI CAL
>
>> +	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);
> This function sets MIPI_CAL_CLKEN_OVR bit, does it mean that MIPI clock
> becomes always-ON?
>
> I don't see where MIPI_CAL_CLKEN_OVR is unset.

CLKEN_OVR was always kept enabled in the driver prior to my patch and I 
was not touching that.

But as we are turning ON/OFF MIPI clock itself no need to unset CLKEN_OVR

>
>>   	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
>>

  reply index

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 20:57 [RFC PATCH v5 00/14] Support for Tegra video capture from external sensor Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 01/14] i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM Sowjanya Komatineni
2020-07-28 16:33   ` Wolfram Sang
2020-07-27 20:57 ` [RFC PATCH v5 02/14] i2c: tegra: Remove NULL pointer check before clk_enable/disable/prepare/unprepare Sowjanya Komatineni
2020-07-28 16:33   ` Wolfram Sang
2020-07-27 20:57 ` [RFC PATCH v5 03/14] i2c: tegra: Fix the error path in tegra_i2c_runtime_resume Sowjanya Komatineni
2020-07-28 16:33   ` Wolfram Sang
2020-07-27 20:57 ` [RFC PATCH v5 04/14] i2c: tegra: Fix runtime resume to re-init VI I2C Sowjanya Komatineni
2020-07-28 16:33   ` Wolfram Sang
2020-07-27 20:57 ` [RFC PATCH v5 05/14] i2c: tegra: Avoid tegra_i2c_init_dma() for Tegra210 vi i2c Sowjanya Komatineni
2020-07-28 16:34   ` Wolfram Sang
2020-07-27 20:57 ` [RFC PATCH v5 06/14] media: tegra-video: Fix channel format alignment Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 07/14] media: tegra-video: Enable TPG based on kernel config Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 08/14] media: tegra-video: Update format lookup to offset based Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 09/14] dt-bindings: tegra: Update VI and CSI bindings with port info Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 10/14] media: tegra-video: Add support for external sensor capture Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 11/14] media: tegra-video: Add support for selection ioctl ops Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 12/14] gpu: host1x: mipi: Keep MIPI clock enabled till calibration is done Sowjanya Komatineni
2020-07-28 11:03   ` Dmitry Osipenko
2020-07-28 16:04     ` Sowjanya Komatineni [this message]
2020-07-29 17:08       ` Dmitry Osipenko
2020-07-29 17:55         ` Sowjanya Komatineni
2020-07-29 23:42           ` Dmitry Osipenko
2020-07-29 23:54             ` Sowjanya Komatineni
2020-07-30  0:31               ` Dmitry Osipenko
2020-07-27 20:57 ` [RFC PATCH v5 13/14] media: tegra-video: Add CSI MIPI pads calibration Sowjanya Komatineni
2020-07-28 10:30   ` Dmitry Osipenko
2020-07-28 15:59     ` Sowjanya Komatineni
2020-07-28 19:43       ` Sowjanya Komatineni
2020-07-29 23:25       ` Dmitry Osipenko
2020-07-29 23:59         ` Sowjanya Komatineni
2020-07-30  0:27           ` Sowjanya Komatineni
2020-07-30  0:43             ` Dmitry Osipenko
2020-07-30  0:52               ` Sowjanya Komatineni
2020-07-30  0:55                 ` Sowjanya Komatineni
2020-07-30  0:53                   ` Dmitry Osipenko
2020-07-30  1:06                     ` Sowjanya Komatineni
2020-07-30  1:10                       ` Dmitry Osipenko
2020-07-30  0:47             ` Sowjanya Komatineni
2020-07-27 20:57 ` [RFC PATCH v5 14/14] media: tegra-video: Compute settle times based on the clock rate Sowjanya Komatineni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69903c67-8e5f-11c2-45ec-c76b97634aba@nvidia.com \
    --to=skomatineni@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=digetx@gmail.com \
    --cc=frankc@nvidia.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jonathanh@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=sboyd@kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Tegra Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-tegra/0 linux-tegra/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-tegra linux-tegra/ https://lore.kernel.org/linux-tegra \
		linux-tegra@vger.kernel.org
	public-inbox-index linux-tegra

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-tegra


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git