Skip to contentSkip to conversation

media: i2c: imx219: add 1% tolerance on clock frequency

PATCH In review [email protected] 2 participants 2 messages Dec 22, 2020 – Feb 2, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 media: i2c: imx219: add 1% tolerance on clock frequency

From: Michael Srba <[email protected]>

This patch adds 1% tolerance on input clock frequency, similar to other camera sensor drivers.

---

changes since v1: default to exactly 24MHz when clock-frequency is not present
changes since v2: remove the ability to set the clock to a specific frequency, since assigned-clocks + assigned-clock-rates can be used 1:1 for the same purpose

---
 drivers/media/i2c/imx219.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/imx219.c +2 -1
index f64c0ef7a897..fd2157eadac4 100644
@@ -1443,8 +1443,9 @@ static int imx219_probe(struct i2c_client *client)
 		return PTR_ERR(imx219->xclk);
 	}
 
+	/* this driver currently expects 24MHz; allow 1% tolerance */
 	imx219->xclk_freq = clk_get_rate(imx219->xclk);
-	if (imx219->xclk_freq != IMX219_XCLK_FREQ) {
+	if (imx219->xclk_freq < 23760000 || imx219->xclk_freq > 24240000) {
 		dev_err(dev, "xclk frequency not supported: %d Hz\n",
 			imx219->xclk_freq);
 		return -EINVAL;
Signature · 1 line
2.29.2
#1 lore raw

Hi Michael,

Quoted 24 lines · On Tue, Dec 22, 2020 at 10:32:31AM +0100, [email protected] wrote:

From: Michael Srba <[email protected]>

This patch adds 1% tolerance on input clock frequency, similar to other camera sensor drivers.

---

changes since v1: default to exactly 24MHz when clock-frequency is not present
changes since v2: remove the ability to set the clock to a specific frequency, since assigned-clocks + assigned-clock-rates can be used 1:1 for the same purpose

---
 drivers/media/i2c/imx219.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/imx219.c +0 -0
index f64c0ef7a897..fd2157eadac4 100644

drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1448

Quoted 7 lines
drivers/media/i2c/imx219.c +2 -1
@@ -1443,8 +1443,9 @@ static int imx219_probe(struct i2c_client *client)
 		return PTR_ERR(imx219->xclk);
 	}
 
+	/* this driver currently expects 24MHz; allow 1% tolerance */
 	imx219->xclk_freq = clk_get_rate(imx219->xclk);
-	if (imx219->xclk_freq != IMX219_XCLK_FREQ) {
+	if (imx219->xclk_freq < 23760000 || imx219->xclk_freq > 24240000) {

Where do you need this? Do you have a system where you get a frequency that's a bit off?

I don't think this is the right way to fix this but on the other hand for register list based drivers there hardly is one.

Quoted 3 lines
drivers/media/i2c/imx219.c +0 -0
 		dev_err(dev, "xclk frequency not supported: %d Hz\n",
 			imx219->xclk_freq);
 		return -EINVAL;
Signature · 3 lines
Regards,

Sakari Ailus