All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo@jmondi.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>,
	krzysztof.kozlowski@canonical.com,
	jeanmichel.hautbois@ideasonboard.com,
	paul.kocialkowski@bootlin.com, sakari.ailus@iki.fi,
	paul.elder@ideasonboard.com,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	"open list:OMNIVISION OV5670 SENSOR DRIVER" 
	<linux-media@vger.kernel.org>
Subject: Re: [PATCH v2 3/8] media: i2c: ov5670: Probe clocks with OF
Date: Tue, 15 Mar 2022 09:46:18 +0100	[thread overview]
Message-ID: <20220315084618.ol6ekvgvn5ldgif7@uno.localdomain> (raw)
In-Reply-To: <YjBKQrdiOo1/EWck@pendragon.ideasonboard.com>

Hi Laurent,

On Tue, Mar 15, 2022 at 10:11:46AM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Mon, Mar 14, 2022 at 05:27:09PM +0100, 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'
> > if the no clock device reference is available.
> >
> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> >  drivers/media/i2c/ov5670.c | 21 +++++++++++++++++----
> >  1 file changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
> > index 721441024598..25d792794fc7 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>
> > @@ -1819,6 +1820,8 @@ struct ov5670 {
> >  	struct v4l2_subdev sd;
> >  	struct media_pad pad;
> >
> > +	struct clk *clk;
> > +
> >  	struct v4l2_ctrl_handler ctrl_handler;
> >  	/* V4L2 Controls */
> >  	struct v4l2_ctrl *link_freq;
> > @@ -2478,10 +2481,6 @@ static int ov5670_probe(struct i2c_client *client)
> >  	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 +2488,20 @@ static int ov5670_probe(struct i2c_client *client)
> >  		goto error_print;
> >  	}
> >
> > +	/* OF uses the common clock framework, ACPI uses "clock-frequency". */
> > +	ov5670->clk = devm_clk_get_optional(&client->dev, NULL);
> > +	if (IS_ERR(ov5670->clk))
> > +		return dev_err_probe(&client->dev, PTR_ERR(ov5670->clk),
> > +				     "error getting clock\n");
> > +
> > +	if (ov5670->clk)
> > +		input_clk = clk_get_rate(ov5670->clk);
> > +	else
> > +		device_property_read_u32(&client->dev, "clock-frequency",
> > +					 &input_clk);
>
> This will try to use the clock-frequency property on OF-based systems if
> no clock is specified. Could we instead have
>

'clocks' is listed as a required property in the OF bindings and my
understanding is that driver assume DTS are correct.

> 	if (probed through OF) {

Otherwise yes, I can check for dev->of_node
But again, I don't think drivers should have to work-around broken DTS

> 		use clock
> 	} else {
> 		use clock-frequency
> 	}
>
> ?
>
> > +	if (input_clk != 19200000)
> > +		return -EINVAL;
> > +
> >  	/* Initialize subdev */
> >  	v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops);
> >
>
> --
> Regards,
>
> Laurent Pinchart

  reply	other threads:[~2022-03-15  8:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 16:27 [PATCH v2 0/8] media: i2c: ov5670: OF support, runtime_pm, regulators Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 1/8] media: dt-bindings: i2c: Document ov5670 Jacopo Mondi
2022-03-15  7:32   ` Krzysztof Kozlowski
2022-03-15  7:59     ` Sakari Ailus
2022-03-15  8:03       ` Krzysztof Kozlowski
2022-03-15 12:47         ` Sakari Ailus
2022-03-15 12:57           ` Krzysztof Kozlowski
2022-03-15 13:01           ` Laurent Pinchart
2022-03-15 20:30             ` Sakari Ailus
2022-03-15  8:09       ` Laurent Pinchart
2022-03-15  8:41     ` Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 2/8] media: i2c: ov5670: Allow probing with OF Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 3/8] media: i2c: ov5670: Probe clocks " Jacopo Mondi
2022-03-15  8:11   ` Laurent Pinchart
2022-03-15  8:46     ` Jacopo Mondi [this message]
2022-03-15  8:52       ` Krzysztof Kozlowski
2022-03-15  8:56       ` Laurent Pinchart
2022-03-16  8:04         ` Sakari Ailus
2022-03-14 16:27 ` [PATCH v2 4/8] media: i2c: ov5670: Probe regulators Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 5/8] media: i2c: ov5670: Probe GPIOs Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 6/8] media: i2c: ov5670: Add runtime_pm operations Jacopo Mondi
2022-03-14 16:27 ` [PATCH v2 7/8] media: i2c: ov5670: Implement init_cfg Jacopo Mondi
2022-03-15  8:13   ` Laurent Pinchart
2022-03-14 16:27 ` [PATCH v2 8/8] media: i2c: ov5670: Add .get_selection() support Jacopo Mondi
2022-03-15  4:18   ` kernel test robot
2022-03-15 16:55     ` Nathan Chancellor
2022-03-15 16:55       ` Nathan Chancellor
2022-03-15  8:19   ` Laurent Pinchart

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=20220315084618.ol6ekvgvn5ldgif7@uno.localdomain \
    --to=jacopo@jmondi.org \
    --cc=chiranjeevi.rapolu@intel.com \
    --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 \
    --cc=sakari.ailus@iki.fi \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.