62 lines
1.9 KiB
Diff
62 lines
1.9 KiB
Diff
|
From aff2d5377d23dbb0ea1d2a7bf275c0b37ed9ec7f Mon Sep 17 00:00:00 2001
|
||
|
From: Ondrej Jirman <megi@xff.cz>
|
||
|
Date: Sun, 22 May 2022 16:40:22 +0200
|
||
|
Subject: [PATCH 336/464] media: i2c: imx258: Set xvclk rate before each power
|
||
|
on
|
||
|
|
||
|
This is to be able to share clock with another sensor driver
|
||
|
which expects a different clock frequency.
|
||
|
|
||
|
Signed-off-by: Ondrej Jirman <megi@xff.cz>
|
||
|
---
|
||
|
drivers/media/i2c/imx258.c | 24 ++++++++++++++++++------
|
||
|
1 file changed, 18 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
|
||
|
index 5abd20219bd0..6d962822bafd 100644
|
||
|
--- a/drivers/media/i2c/imx258.c
|
||
|
+++ b/drivers/media/i2c/imx258.c
|
||
|
@@ -1025,8 +1025,23 @@ static int imx258_power_on(struct device *dev)
|
||
|
{
|
||
|
struct v4l2_subdev *sd = dev_get_drvdata(dev);
|
||
|
struct imx258 *imx258 = to_imx258(sd);
|
||
|
+ u32 val = 0;
|
||
|
int ret;
|
||
|
|
||
|
+ if (imx258->clk) {
|
||
|
+ ret = clk_set_rate(imx258->clk, IMX258_INPUT_CLOCK_FREQ);
|
||
|
+ if (ret < 0)
|
||
|
+ dev_warn(dev, "Failed to set clk rate\n");
|
||
|
+
|
||
|
+ val = clk_get_rate(imx258->clk);
|
||
|
+ if (val < IMX258_INPUT_CLOCK_FREQ_MIN ||
|
||
|
+ val > IMX258_INPUT_CLOCK_FREQ_MAX) {
|
||
|
+ dev_err(dev, "clk mismatched, expecting %u, got %u Hz\n",
|
||
|
+ IMX258_INPUT_CLOCK_FREQ, val);
|
||
|
+ return -EINVAL;
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
ret = regulator_bulk_enable(IMX258_SUPPLY_COUNT, imx258->supplies);
|
||
|
if (ret) {
|
||
|
dev_err(dev, "failed to enable regulators\n");
|
||
|
@@ -1338,12 +1353,9 @@ static int imx258_probe(struct i2c_client *client)
|
||
|
val = clk_get_rate(imx258->clk);
|
||
|
}
|
||
|
|
||
|
- if (val < IMX258_INPUT_CLOCK_FREQ_MIN
|
||
|
- || val > IMX258_INPUT_CLOCK_FREQ_MAX) {
|
||
|
- dev_err(&client->dev, "input clock frequency %u not supported\n",
|
||
|
- val);
|
||
|
- return -EINVAL;
|
||
|
- }
|
||
|
+ //XXX: the driver just checked for the clock to be as expected here
|
||
|
+ // but we now just configure the clock to expected value before power on
|
||
|
+ // if possible
|
||
|
|
||
|
for (i = 0; i < IMX258_SUPPLY_COUNT; i++)
|
||
|
imx258->supplies[i].supply = imx258_supply_names[i];
|
||
|
--
|
||
|
2.34.1
|
||
|
|