LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: jacopo mondi <jacopo@jmondi.org>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	hans.verkuil@cisco.com, mchehab@kernel.org, robh+dt@kernel.org,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] media: i2c: mt9t112: Add device tree support
Date: Mon, 14 May 2018 16:30:44 +0200	[thread overview]
Message-ID: <20180514143044.GK5956@w540> (raw)
In-Reply-To: <20180507093219.hrhaliadccaytenj@valkosipuli.retiisi.org.uk>

[-- Attachment #1: Type: text/plain, Size: 3672 bytes --]

Hi Sakari,

On Mon, May 07, 2018 at 12:32:19PM +0300, Sakari Ailus wrote:
> Hi Jacopo,
>
> On Wed, Apr 25, 2018 at 01:00:14PM +0200, Jacopo Mondi wrote:

[snip]

> >  static int mt9t112_probe(struct i2c_client *client,
> >  			 const struct i2c_device_id *did)
> >  {
> >  	struct mt9t112_priv *priv;
> >  	int ret;
> >
> > -	if (!client->dev.platform_data) {
> > +	if (!client->dev.of_node && !client->dev.platform_data) {
> >  		dev_err(&client->dev, "mt9t112: missing platform data!\n");
> >  		return -EINVAL;
> >  	}
> > @@ -1081,23 +1118,39 @@ static int mt9t112_probe(struct i2c_client *client,
> >  	if (!priv)
> >  		return -ENOMEM;
> >
> > -	priv->info = client->dev.platform_data;
> >  	priv->init_done = false;
> > -
> > -	v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
> > -
> > -	priv->clk = devm_clk_get(&client->dev, "extclk");
> > -	if (PTR_ERR(priv->clk) == -ENOENT) {
> > +	priv->dev = &client->dev;
> > +
> > +	if (client->dev.platform_data) {
> > +		priv->info = client->dev.platform_data;
> > +
> > +		priv->clk = devm_clk_get(&client->dev, "extclk");
>
> extclk needs to be documented in DT binding documentation.
>
> > +		if (PTR_ERR(priv->clk) == -ENOENT) {
> > +			priv->clk = NULL;
> > +		} else if (IS_ERR(priv->clk)) {
> > +			dev_err(&client->dev,
> > +				"Unable to get clock \"extclk\"\n");
> > +			return PTR_ERR(priv->clk);
> > +		}
> > +	} else {
> > +		/*
> > +		 * External clock frequencies != 24MHz are only supported
> > +		 * for non-OF systems.
> > +		 */
>
> Shouldn't you actually set the frequency? Or perhaps even better to check
> it, and use assigned-clocks and assigned-clock-rates properties?
>

I might be confused, but my intention was to use an external clock
reference, with a configurable frequency only in the platform data use
case. As you can see in this 'else' branch, in OF case, the priv->clk
field is null, and all the PLL and clock computations are performed
assuming a 24MHz input clock.

In my opinion, as the driver when running on OF systems does not
get any reference to 'extclk' clock, it should not be documented in
bindings. Do you agree?

Thanks
   j

> >  		priv->clk = NULL;
> > -	} else if (IS_ERR(priv->clk)) {
> > -		dev_err(&client->dev, "Unable to get clock \"extclk\"\n");
> > -		return PTR_ERR(priv->clk);
> > +		priv->info = &mt9t112_default_pdata_24MHz;
> > +
> > +		ret = mt9t112_parse_dt(priv);
> > +		if (ret)
> > +			return ret;
> >  	}
> >
> > -	priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
> > +	v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
> > +
> > +	priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
> >  						     GPIOD_OUT_HIGH);
> >  	if (IS_ERR(priv->standby_gpio)) {
> > -		dev_err(&client->dev, "Unable to get gpio \"standby\"\n");
> > +		dev_err(&client->dev, "Unable to get gpio \"powerdown\"\n");
> >  		return PTR_ERR(priv->standby_gpio);
> >  	}
> >
> > @@ -1124,9 +1177,19 @@ static const struct i2c_device_id mt9t112_id[] = {
> >  };
> >  MODULE_DEVICE_TABLE(i2c, mt9t112_id);
> >
> > +#if IS_ENABLED(CONFIG_OF)
> > +static const struct of_device_id mt9t112_of_match[] = {
> > +	{ .compatible = "micron,mt9t111", },
> > +	{ .compatible = "micron,mt9t112", },
> > +	{ /* sentinel */ },
> > +};
> > +MODULE_DEVICE_TABLE(of, mt9t112_of_match);
> > +#endif
> > +
> >  static struct i2c_driver mt9t112_i2c_driver = {
> >  	.driver = {
> >  		.name = "mt9t112",
> > +		.of_match_table = of_match_ptr(mt9t112_of_match),
>
> No need to use of_match_ptr().
>
> >  	},
> >  	.probe    = mt9t112_probe,
> >  	.remove   = mt9t112_remove,
>
> --
> Sakari Ailus
> e-mail: sakari.ailus@iki.fi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2018-05-14 14:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 11:00 [PATCH 0/2] media: i2c: mt9t112: Add OF " Jacopo Mondi
2018-04-25 11:00 ` [PATCH 1/2] dt-bindings: media: i2c: Add mt9t111 image sensor Jacopo Mondi
2018-05-01 14:28   ` Rob Herring
2018-05-07  9:17   ` Sakari Ailus
2018-04-25 11:00 ` [PATCH 2/2] media: i2c: mt9t112: Add device tree support Jacopo Mondi
2018-05-07  9:32   ` Sakari Ailus
2018-05-14 14:30     ` jacopo mondi [this message]
2018-05-14 21:50       ` Sakari Ailus
2018-05-15  7:10         ` 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=20180514143044.GK5956@w540 \
    --to=jacopo@jmondi.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hans.verkuil@cisco.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --subject='Re: [PATCH 2/2] media: i2c: mt9t112: Add device tree support' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).