mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 14:13:16 +00:00
793f8ab62c
Add kernel patches for version 6.1. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
114 lines
3.2 KiB
Diff
114 lines
3.2 KiB
Diff
From 88c013f4c7e60431bca7bc6487971f671397e0fd Mon Sep 17 00:00:00 2001
|
|
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Date: Mon, 16 Jan 2023 15:44:47 +0100
|
|
Subject: [PATCH] media: i2c: imx290: Factor out clock initialization
|
|
to separate function
|
|
|
|
Upstream commit e5d363ca82b9
|
|
|
|
Move the external clock initialization code from probe() to a separate
|
|
function to improve readability. No functional change intended.
|
|
|
|
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
|
|
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
|
|
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
|
|
---
|
|
drivers/media/i2c/imx290.c | 57 +++++++++++++++++++++++---------------
|
|
1 file changed, 35 insertions(+), 22 deletions(-)
|
|
|
|
--- a/drivers/media/i2c/imx290.c
|
|
+++ b/drivers/media/i2c/imx290.c
|
|
@@ -1120,6 +1120,34 @@ static int imx290_get_regulators(struct
|
|
imx290->supplies);
|
|
}
|
|
|
|
+static int imx290_init_clk(struct imx290 *imx290)
|
|
+{
|
|
+ u32 xclk_freq;
|
|
+ int ret;
|
|
+
|
|
+ ret = fwnode_property_read_u32(dev_fwnode(imx290->dev),
|
|
+ "clock-frequency", &xclk_freq);
|
|
+ if (ret) {
|
|
+ dev_err(imx290->dev, "Could not get xclk frequency\n");
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ /* external clock must be 37.125 MHz */
|
|
+ if (xclk_freq != 37125000) {
|
|
+ dev_err(imx290->dev, "External clock frequency %u is not supported\n",
|
|
+ xclk_freq);
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ ret = clk_set_rate(imx290->xclk, xclk_freq);
|
|
+ if (ret) {
|
|
+ dev_err(imx290->dev, "Could not set xclk frequency\n");
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
/*
|
|
* Returns 0 if all link frequencies used by the driver for the given number
|
|
* of MIPI data lanes are mentioned in the device tree, or the value of the
|
|
@@ -1204,7 +1232,6 @@ static int imx290_probe(struct i2c_clien
|
|
{
|
|
struct device *dev = &client->dev;
|
|
struct imx290 *imx290;
|
|
- u32 xclk_freq;
|
|
int ret;
|
|
|
|
imx290 = devm_kzalloc(dev, sizeof(*imx290), GFP_KERNEL);
|
|
@@ -1222,32 +1249,12 @@ static int imx290_probe(struct i2c_clien
|
|
if (ret)
|
|
return ret;
|
|
|
|
- /* get system clock (xclk) */
|
|
+ /* Acquire resources. */
|
|
imx290->xclk = devm_clk_get(dev, "xclk");
|
|
if (IS_ERR(imx290->xclk))
|
|
return dev_err_probe(dev, PTR_ERR(imx290->xclk),
|
|
"Could not get xclk");
|
|
|
|
- ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
|
|
- &xclk_freq);
|
|
- if (ret) {
|
|
- dev_err(dev, "Could not get xclk frequency\n");
|
|
- return ret;
|
|
- }
|
|
-
|
|
- /* external clock must be 37.125 MHz */
|
|
- if (xclk_freq != 37125000) {
|
|
- dev_err(dev, "External clock frequency %u is not supported\n",
|
|
- xclk_freq);
|
|
- return -EINVAL;
|
|
- }
|
|
-
|
|
- ret = clk_set_rate(imx290->xclk, xclk_freq);
|
|
- if (ret) {
|
|
- dev_err(dev, "Could not set xclk frequency\n");
|
|
- return ret;
|
|
- }
|
|
-
|
|
ret = imx290_get_regulators(dev, imx290);
|
|
if (ret < 0)
|
|
return dev_err_probe(dev, ret, "Cannot get regulators\n");
|
|
@@ -1258,8 +1265,14 @@ static int imx290_probe(struct i2c_clien
|
|
return dev_err_probe(dev, PTR_ERR(imx290->rst_gpio),
|
|
"Cannot get reset gpio\n");
|
|
|
|
+ /* Initialize external clock frequency. */
|
|
+ ret = imx290_init_clk(imx290);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
mutex_init(&imx290->lock);
|
|
|
|
+ /* Initialize and register subdev. */
|
|
ret = imx290_subdev_init(imx290);
|
|
if (ret)
|
|
goto err_mutex;
|