diff mbox series

[v3,1/1] media: i2c: imx219: add 1% tolerance on clock frequency

Message ID 20201222093231.13438-1-michael.srba@seznam.cz
State New
Headers show
Series [v3,1/1] media: i2c: imx219: add 1% tolerance on clock frequency | expand

Commit Message

Michael Srba Dec. 22, 2020, 9:32 a.m. UTC
From: Michael Srba <Michael.Srba@seznam.cz>

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

Signed-off-by: Michael Srba <Michael.Srba@seznam.cz>

---

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(-)

Comments

Sakari Ailus Feb. 2, 2021, 10:55 p.m. UTC | #1
Hi Michael,

On Tue, Dec 22, 2020 at 10:32:31AM +0100, michael.srba@seznam.cz wrote:
> From: Michael Srba <Michael.Srba@seznam.cz>

> 

> This patch adds 1% tolerance on input clock frequency, similar to other

> camera sensor drivers.

> 

> Signed-off-by: Michael Srba <Michael.Srba@seznam.cz>

> 

> ---

> 

> 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(-)

> 

> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c

> index f64c0ef7a897..fd2157eadac4 100644

> --- a/drivers/media/i2c/imx219.c

> +++ b/drivers/media/i2c/imx219.c

> @@ -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.

>  		dev_err(dev, "xclk frequency not supported: %d Hz\n",

>  			imx219->xclk_freq);

>  		return -EINVAL;


-- 
Regards,

Sakari Ailus
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index f64c0ef7a897..fd2157eadac4 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -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;