public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>,
	krzysztof.kozlowski@canonical.com,
	jeanmichel.hautbois@ideasonboard.com,
	laurent.pinchart@ideasonboard.com, paul.kocialkowski@bootlin.com,
	paul.elder@ideasonboard.com,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	"open list:OMNIVISION OV5670 SENSOR DRIVER" 
	<linux-media@vger.kernel.org>
Subject: Re: [PATCH v3 3/8] media: i2c: ov5670: Probe clocks with OF
Date: Wed, 30 Mar 2022 08:31:18 +0300	[thread overview]
Message-ID: <YkPrJg64PpiOB5M/@valkosipuli.retiisi.eu> (raw)
In-Reply-To: <20220329090133.338073-4-jacopo@jmondi.org>

Hi Jacopo,

On Tue, Mar 29, 2022 at 11:01:28AM +0200, Jacopo Mondi wrote:
> Add support for probing the main system clock using the common clock
> framework and its OF bindings.
> 
> Maintain ACPI compatibility by falling back to parse 'clock-frequency'.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  drivers/media/i2c/ov5670.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
> index 721441024598..1cc312981c82 100644
> --- a/drivers/media/i2c/ov5670.c
> +++ b/drivers/media/i2c/ov5670.c
> @@ -2,6 +2,7 @@
>  // Copyright (c) 2017 Intel Corporation.
>  
>  #include <linux/acpi.h>
> +#include <linux/clk.h>
>  #include <linux/i2c.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/module.h>
> @@ -2475,13 +2476,10 @@ static int ov5670_probe(struct i2c_client *client)
>  	struct ov5670 *ov5670;
>  	const char *err_msg;
>  	u32 input_clk = 0;
> +	struct clk *clk;
>  	bool full_power;
>  	int ret;
>  
> -	device_property_read_u32(&client->dev, "clock-frequency", &input_clk);
> -	if (input_clk != 19200000)
> -		return -EINVAL;
> -
>  	ov5670 = devm_kzalloc(&client->dev, sizeof(*ov5670), GFP_KERNEL);
>  	if (!ov5670) {
>  		ret = -ENOMEM;
> @@ -2489,6 +2487,22 @@ static int ov5670_probe(struct i2c_client *client)
>  		goto error_print;
>  	}
>  
> +	/* OF uses the common clock framework, ACPI uses "clock-frequency". */
> +	if (is_of_node(dev_fwnode(&client->dev))) {
> +		clk = devm_clk_get(&client->dev, NULL);
> +		if (IS_ERR(clk))
> +			return dev_err_probe(&client->dev, PTR_ERR(clk),
> +					     "error getting clock\n");
> +
> +		input_clk = clk_get_rate(clk);
> +	} else {
> +		device_property_read_u32(&client->dev, "clock-frequency",
> +					 &input_clk);
> +	}
> +
> +	if (input_clk != 19200000)
> +		return -EINVAL;

You could tell what that wrong frequency is. Up to you.

> +
>  	/* Initialize subdev */
>  	v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops);
>  

-- 
Regards,

Sakari Ailus

  reply	other threads:[~2022-03-30  5:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  9:01 [PATCH v3 0/8] media: i2c: ov5670: OF support, runtime_pm, regulators Jacopo Mondi
2022-03-29  9:01 ` [PATCH v3 1/8] media: dt-bindings: i2c: Document ov5670 Jacopo Mondi
2022-03-29  9:01 ` [PATCH v3 2/8] media: i2c: ov5670: Allow probing with OF Jacopo Mondi
2022-03-30  5:30   ` Sakari Ailus
2022-03-29  9:01 ` [PATCH v3 3/8] media: i2c: ov5670: Probe clocks " Jacopo Mondi
2022-03-30  5:31   ` Sakari Ailus [this message]
2022-03-29  9:01 ` [PATCH v3 4/8] media: i2c: ov5670: Probe regulators Jacopo Mondi
2022-03-29  9:01 ` [PATCH v3 5/8] media: i2c: ov5670: Probe GPIOs Jacopo Mondi
2022-03-29  9:01 ` [PATCH v3 6/8] media: i2c: ov5670: Add runtime_pm operations Jacopo Mondi
2022-03-31 10:08   ` Sakari Ailus
2022-03-31 10:33     ` Laurent Pinchart
2022-03-31 12:34       ` Sakari Ailus
2022-04-27  9:57   ` Sakari Ailus
2022-04-27  9:59     ` Sakari Ailus
2022-03-29  9:01 ` [PATCH v3 7/8] media: i2c: ov5670: Implement init_cfg Jacopo Mondi
2022-03-30  5:33   ` Sakari Ailus
2022-03-29  9:01 ` [PATCH v3 8/8] media: i2c: ov5670: Add .get_selection() support Jacopo Mondi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YkPrJg64PpiOB5M/@valkosipuli.retiisi.eu \
    --to=sakari.ailus@iki.fi \
    --cc=chiranjeevi.rapolu@intel.com \
    --cc=jacopo@jmondi.org \
    --cc=jeanmichel.hautbois@ideasonboard.com \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=paul.elder@ideasonboard.com \
    --cc=paul.kocialkowski@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox