Re: [PATCH v1 07/19] staging: media: tegra-video: csi: parametrize MIPI calibration device presence

From: Mikko Perttunen
Date: Mon Sep 01 2025 - 20:47:21 EST


On Tuesday, August 19, 2025 9:16 PM Svyatoslav Ryhel wrote:
> Dedicated MIPI calibration block appears only in Tegra114, before Tegra114
> all MIPI calibration pads were part of VI block.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
> ---
> drivers/staging/media/tegra-video/csi.c | 12 +++++++-----
> drivers/staging/media/tegra-video/csi.h | 1 +
> drivers/staging/media/tegra-video/tegra210.c | 1 +
> 3 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/media/tegra-video/csi.c
> b/drivers/staging/media/tegra-video/csi.c index 74c92db1032f..2f9907a20db1
> 100644
> --- a/drivers/staging/media/tegra-video/csi.c
> +++ b/drivers/staging/media/tegra-video/csi.c
> @@ -485,11 +485,13 @@ static int tegra_csi_channel_alloc(struct tegra_csi
> *csi, if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG))
> return 0;
>
> - chan->mipi = tegra_mipi_request(csi->dev, node);
> - if (IS_ERR(chan->mipi)) {
> - ret = PTR_ERR(chan->mipi);
> - chan->mipi = NULL;
> - dev_err(csi->dev, "failed to get mipi device: %d\n", ret);
> + if (csi->soc->has_mipi_calibration) {
> + chan->mipi = tegra_mipi_request(csi->dev, node);

The way I would read 'soc->has_mipi_calibration' is that this device (CSI)
contains the MIPI calibration hardware. I.e. the opposite of here. I would
invert the logic and optionally call it e.g. 'internal_mipi_calib'.

A cleaner way to do this might be to always call tegra_mipi_request et al. --
on pre-Tegra114 SoCs this would just call back to the VI/CSI driver using the
callbacks registered in the MIPI driver as we discussed before. That way the
CSI driver won't need separate code paths for SoCs with internal MIPI
calibration and SoCs with the external MIPI calibration device.

Cheers,
Mikko

> + if (IS_ERR(chan->mipi)) {
> + ret = PTR_ERR(chan->mipi);
> + chan->mipi = NULL;
> + dev_err(csi->dev, "failed to get mipi device:
%d\n", ret);
> + }
> }
>
> return ret;
> diff --git a/drivers/staging/media/tegra-video/csi.h
> b/drivers/staging/media/tegra-video/csi.h index 3ed2dbc73ce9..400b913bb1cb
> 100644
> --- a/drivers/staging/media/tegra-video/csi.h
> +++ b/drivers/staging/media/tegra-video/csi.h
> @@ -128,6 +128,7 @@ struct tegra_csi_soc {
> unsigned int num_clks;
> const struct tpg_framerate *tpg_frmrate_table;
> unsigned int tpg_frmrate_table_size;
> + bool has_mipi_calibration;
> };
>
> /**
> diff --git a/drivers/staging/media/tegra-video/tegra210.c
> b/drivers/staging/media/tegra-video/tegra210.c index
> da99f19a39e7..305472e94af4 100644
> --- a/drivers/staging/media/tegra-video/tegra210.c
> +++ b/drivers/staging/media/tegra-video/tegra210.c
> @@ -1218,4 +1218,5 @@ const struct tegra_csi_soc tegra210_csi_soc = {
> .num_clks = ARRAY_SIZE(tegra210_csi_cil_clks),
> .tpg_frmrate_table = tegra210_tpg_frmrate_table,
> .tpg_frmrate_table_size = ARRAY_SIZE(tegra210_tpg_frmrate_table),
> + .has_mipi_calibration = true,
> };