]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: imx-mipi-csis: Only set clock rate when specified in DT
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 22 Aug 2025 00:27:29 +0000 (03:27 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:10 +0000 (15:37 -0500)
[ Upstream commit 65673c6e33cf46f220cc5774166b373b3c087739 ]

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.

Link: https://lore.kernel.org/r/20250822002734.23516-10-laurent.pinchart@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/nxp/imx-mipi-csis.c

index 2beb5f43c2c0121378c03efa61aedde335d15403..cea017a2b14ec761c60f7f56c035e85b87cf5f24 100644 (file)
 #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;
@@ -704,12 +702,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;
 }
@@ -1413,9 +1416,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;
 }