public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org,
	Isaac Scott <isaac.scott@ideasonboard.com>,
	Rui Miguel Silva <rmfrfs@gmail.com>,
	Martin Kepplinger <martink@posteo.de>,
	Purism Kernel Team <kernel@puri.sm>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	devicetree@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 08/12] media: imx-mipi-csis: Only set clock rate when specified in DT
Date: Thu, 21 Aug 2025 11:30:20 -0400	[thread overview]
Message-ID: <aKc7jGu1oz89jyrS@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250821000944.27849-9-laurent.pinchart@ideasonboard.com>

On Thu, Aug 21, 2025 at 03:09:40AM +0300, Laurent Pinchart wrote:
> The imx-mipi-csis driver sets the rate of the wrap clock to the value
> specified in the device tree's "clock-frequency" property, and defaults
> to 166 MHz otherwise. This is a historical mistake, as clock rate
> selection should have been left to the assigned-clock-rates property.
>
> Honouring the clock-frequency property can't be removed without breaking
> backwards compatibility, and the corresponding code isn't very
> intrusive. The 166 MHz default, on the other hand, prevents
> configuration of the clock rate through assigned-clock-rates, as the
> driver immediately overwrites the rate. This behaviour is confusing and
> has cost debugging time.
>
> There is little value in a 166 MHz default. All mainline device tree
> sources that enable the CSIS specify a clock-frequency explicitly, and
> the default wrap clock configuration on supported platforms is at least
> as high as 166 MHz. Drop the default, and only set the clock rate
> manually when the clock-frequency property is specified.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> ---
>  drivers/media/platform/nxp/imx-mipi-csis.c | 23 +++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index 67da8326540b..83ba68a20bd1 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -230,8 +230,6 @@
>  #define MIPI_CSIS_PKTDATA_EVEN			0x3000
>  #define MIPI_CSIS_PKTDATA_SIZE			SZ_4K
>
> -#define DEFAULT_SCLK_CSIS_FREQ			166000000UL
> -
>  struct mipi_csis_event {
>  	bool debug;
>  	u32 mask;
> @@ -708,12 +706,17 @@ static int mipi_csis_clk_get(struct mipi_csis_device *csis)
>  	if (ret < 0)
>  		return ret;
>
> -	/* Set clock rate */
> -	ret = clk_set_rate(csis->clks[MIPI_CSIS_CLK_WRAP].clk,
> -			   csis->clk_frequency);
> -	if (ret < 0)
> -		dev_err(csis->dev, "set rate=%d failed: %d\n",
> -			csis->clk_frequency, ret);
> +	if (csis->clk_frequency) {
> +		/*
> +		 * Set the clock rate. This is deprecated, for backward
> +		 * compatibility with old device trees.
> +		 */
> +		ret = clk_set_rate(csis->clks[MIPI_CSIS_CLK_WRAP].clk,
> +				   csis->clk_frequency);
> +		if (ret < 0)
> +			dev_err(csis->dev, "set rate=%d failed: %d\n",
> +				csis->clk_frequency, ret);
> +	}
>
>  	return ret;
>  }
> @@ -1417,9 +1420,7 @@ static int mipi_csis_parse_dt(struct mipi_csis_device *csis)
>  {
>  	struct device_node *node = csis->dev->of_node;
>
> -	if (of_property_read_u32(node, "clock-frequency",
> -				 &csis->clk_frequency))
> -		csis->clk_frequency = DEFAULT_SCLK_CSIS_FREQ;
> +	of_property_read_u32(node, "clock-frequency", &csis->clk_frequency);
>
>  	return 0;
>  }
> --
> Regards,
>
> Laurent Pinchart
>


  reply	other threads:[~2025-08-21 19:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-21  0:09 [PATCH v2 00/12] media: imx-mipi-csis: Cleanups and debugging improvements Laurent Pinchart
2025-08-21  0:09 ` [PATCH v2 01/12] media: v4l2-common: Constify media_pad argument to v4l2_get_link_freq() Laurent Pinchart
2025-08-21 15:06   ` Frank Li
2025-08-21  0:09 ` [PATCH v2 02/12] media: imx-mipi-csis: Simplify access to source pad Laurent Pinchart
2025-08-21 15:10   ` Frank Li
2025-08-21 15:44     ` Laurent Pinchart
2025-08-21  0:09 ` [PATCH v2 03/12] media: imx-mipi-csis: Standardize const keyword placement Laurent Pinchart
2025-08-21 15:11   ` Frank Li
2025-08-21  0:09 ` [PATCH v2 04/12] media: imx-mipi-csis: Shorten name of subdev state variables Laurent Pinchart
2025-08-21 15:17   ` Frank Li
2025-08-22  7:18   ` Alexander Stein
2025-08-21  0:09 ` [PATCH v2 05/12] media: imx-mipi-csis: Rename register macros to match reference manual Laurent Pinchart
2025-08-21 15:25   ` Frank Li
2025-08-21 16:06     ` Laurent Pinchart
2025-08-21  0:09 ` [PATCH v2 06/12] media: imx-mipi-csis: Fix field alignment in register dump Laurent Pinchart
2025-08-21 15:26   ` Frank Li
2025-08-21  0:09 ` [PATCH v2 07/12] media: imx-mipi-csis: Log per-lane start of transmission errors Laurent Pinchart
2025-08-21 15:27   ` Frank Li
2025-08-21  0:09 ` [PATCH v2 08/12] media: imx-mipi-csis: Only set clock rate when specified in DT Laurent Pinchart
2025-08-21 15:30   ` Frank Li [this message]
2025-08-21  0:09 ` [PATCH v2 09/12] dt-bindings: media: nxp,imx-mipi-csi2: Mark clock-frequency as deprecated Laurent Pinchart
2025-08-21  0:09 ` [PATCH v2 10/12] dt-bindings: media: nxp,imx-mipi-csi2: Add fsl,num-channels property Laurent Pinchart
2025-08-21  0:09 ` [PATCH v2 11/12] media: imx-mipi-csis: Initial support for multiple output channels Laurent Pinchart
2025-08-21 15:56   ` Frank Li
2025-08-21 16:30     ` Laurent Pinchart
2025-08-21 18:44       ` Frank Li
2025-08-21  0:09 ` [PATCH v2 12/12] arm64: dts: imx8mp: Specify the number of channels for CSI-2 receivers Laurent Pinchart
2025-08-21 16:00   ` Frank Li
2025-08-21 16:42     ` Laurent Pinchart
2025-08-22 13:50   ` Stefan Klug

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=aKc7jGu1oz89jyrS@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=isaac.scott@ideasonboard.com \
    --cc=kernel@pengutronix.de \
    --cc=kernel@puri.sm \
    --cc=krzk+dt@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    --cc=martink@posteo.de \
    --cc=mchehab@kernel.org \
    --cc=rmfrfs@gmail.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox