All of lore.kernel.org
 help / color / mirror / Atom feed
From: "G, Manjunath Kondaiah" <manjugk@ti.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: devicetree-discuss@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
	ben-linux@fluff.org
Subject: Re: [RFC PATCH 5/5] OMAP: I2C: Convert I2C driver to use device tree
Date: Thu, 7 Jul 2011 22:43:49 +0530	[thread overview]
Message-ID: <20110707171349.GC3124@manju-desktop> (raw)
In-Reply-To: <20110706190803.GN4871@ponder.secretlab.ca>

On Wed, Jul 06, 2011 at 01:08:03PM -0600, Grant Likely wrote:
> On Thu, Jun 30, 2011 at 03:07:27PM +0500, G, Manjunath Kondaiah wrote:
> > 
> > The OMAP I2C driver is modified to use platform_device data from
> > device tree data structures.
> > 
> > Signed-off-by: G, Manjunath Kondaiah <manjugk@ti.com>
> 
> Mostly looks good, but a few things that need to be fixed.  You can
> probably even get this change merged for v3.1

Thanks. I will fix the review comments and we can have these changes with
board-omapx-dt.c file so that dt and not dt builds can co exist.

For complete functionality with dt build, omap hwmod needs to be handled
through DT framework. I am waiting for comments from omap hwmod maintainers.

> 
> > ---
> >  drivers/i2c/busses/i2c-omap.c |   30 +++++++++++++++++++++++++++++-
> >  1 files changed, 29 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> > index ae1545b..d4ccc52 100644
> > --- a/drivers/i2c/busses/i2c-omap.c
> > +++ b/drivers/i2c/busses/i2c-omap.c
> > @@ -38,9 +38,13 @@
> >  #include <linux/clk.h>
> >  #include <linux/io.h>
> >  #include <linux/of_i2c.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/of_address.h>
> >  #include <linux/slab.h>
> >  #include <linux/i2c-omap.h>
> >  #include <linux/pm_runtime.h>
> > +#include <plat/i2c.h>
> >  
> >  /* I2C controller revisions */
> >  #define OMAP_I2C_REV_2			0x20
> > @@ -972,6 +976,7 @@ static const struct i2c_algorithm omap_i2c_algo = {
> >  	.functionality	= omap_i2c_func,
> >  };
> >  
> > +static const struct of_device_id omap_i2c_of_match[];
> >  static int __devinit
> >  omap_i2c_probe(struct platform_device *pdev)
> >  {
> > @@ -979,10 +984,15 @@ omap_i2c_probe(struct platform_device *pdev)
> >  	struct i2c_adapter	*adap;
> >  	struct resource		*mem, *irq, *ioarea;
> >  	struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data;
> > +	const struct of_device_id *match;
> >  	irq_handler_t isr;
> >  	int r;
> >  	u32 speed = 0;
> >  
> > +	match = of_match_device(omap_i2c_of_match, &pdev->dev);
> > +	if (!match)
> > +		dev_err(&pdev->dev, "DT: i2c device match not found.......\n");
> > +
> 
> This isn't an error.  It just mean that the device wasn't registered
> from the device tree, and it needs to get its configuration from
> pdata.
> 
> In fact, you don't even need this block since the driver never uses
> the match entry returned by of_match_device()

ok. I will remove this.
> 
> >  	/* NOTE: driver uses the static register mapping */
> >  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >  	if (!mem) {
> > @@ -1007,10 +1017,19 @@ omap_i2c_probe(struct platform_device *pdev)
> >  		r = -ENOMEM;
> >  		goto err_release_region;
> >  	}
> > -
> 
> Don't drop the empty line.
> 
> > +	/* I2C device without DT might use this */
> 
> No need for the comment.
ok
> 
> >  	if (pdata != NULL) {
> >  		speed = pdata->clkrate;
> >  		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
> > +	} else if (pdev->dev.of_node) {
> > +		const unsigned int *prop;
> > +		prop = of_get_property(pdev->dev.of_node,
> > +				"clock-frequency", NULL);
> > +		if (prop)
> > +			speed = be32_to_cpup(prop);
> > +		else
> > +			speed = 100;
> 
> There is a new function that makes this easier.  Do this instead:
> 
> 	speed = 100;
> 	if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", &prop)
> 		speed = prop / 1000000; /* speed in Hz, this might be wrong */
These patches got merged after posting this series. I will take care of it in
the next version.

BTW, I have posted seperate patch to use above API for code optimization.


> 
> > +		dev->set_mpu_wkup_lat = NULL;
> 
> dev is kzalloced, which means set_mpu_wkup_lat is already NULL.
> 
> >  	} else {
> >  		speed = 100;	/* Default speed */
> >  		dev->set_mpu_wkup_lat = NULL;
> > @@ -1045,6 +1064,7 @@ omap_i2c_probe(struct platform_device *pdev)
> >  
> >  	dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff;
> >  
> > +
> 
> Drop the unrelated whitespace change.
> 
> >  	if (dev->rev <= OMAP_I2C_REV_ON_3430)
> >  		dev->errata |= I2C_OMAP3_1P153;
> >  
> > @@ -1073,6 +1093,7 @@ omap_i2c_probe(struct platform_device *pdev)
> >  				       (1000 * speed / 8);
> >  	}
> >  
> > +
> 
> Ditto.
> 
> >  	/* reset ASAP, clearing any IRQs */
> >  	omap_i2c_init(dev);
> >  
> > @@ -1162,6 +1183,12 @@ static int omap_i2c_resume(struct device *dev)
> >  	return 0;
> >  }
> >  
> > +static const struct of_device_id omap_i2c_of_match[] = {
> > +	{.compatible = "ti,omap_i2c", },
> > +	{},
> > +}
> > +MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
> > +
> 
> This needs to be protected with #ifdef CONFIG_OF/#else/#endif.  Don't
> break non-dt builds.
> 

ok. Thanks.

-Manjunath

WARNING: multiple messages have this Message-ID (diff)
From: manjugk@ti.com (G, Manjunath Kondaiah)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 5/5] OMAP: I2C: Convert I2C driver to use device tree
Date: Thu, 7 Jul 2011 22:43:49 +0530	[thread overview]
Message-ID: <20110707171349.GC3124@manju-desktop> (raw)
In-Reply-To: <20110706190803.GN4871@ponder.secretlab.ca>

On Wed, Jul 06, 2011 at 01:08:03PM -0600, Grant Likely wrote:
> On Thu, Jun 30, 2011 at 03:07:27PM +0500, G, Manjunath Kondaiah wrote:
> > 
> > The OMAP I2C driver is modified to use platform_device data from
> > device tree data structures.
> > 
> > Signed-off-by: G, Manjunath Kondaiah <manjugk@ti.com>
> 
> Mostly looks good, but a few things that need to be fixed.  You can
> probably even get this change merged for v3.1

Thanks. I will fix the review comments and we can have these changes with
board-omapx-dt.c file so that dt and not dt builds can co exist.

For complete functionality with dt build, omap hwmod needs to be handled
through DT framework. I am waiting for comments from omap hwmod maintainers.

> 
> > ---
> >  drivers/i2c/busses/i2c-omap.c |   30 +++++++++++++++++++++++++++++-
> >  1 files changed, 29 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> > index ae1545b..d4ccc52 100644
> > --- a/drivers/i2c/busses/i2c-omap.c
> > +++ b/drivers/i2c/busses/i2c-omap.c
> > @@ -38,9 +38,13 @@
> >  #include <linux/clk.h>
> >  #include <linux/io.h>
> >  #include <linux/of_i2c.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/of_address.h>
> >  #include <linux/slab.h>
> >  #include <linux/i2c-omap.h>
> >  #include <linux/pm_runtime.h>
> > +#include <plat/i2c.h>
> >  
> >  /* I2C controller revisions */
> >  #define OMAP_I2C_REV_2			0x20
> > @@ -972,6 +976,7 @@ static const struct i2c_algorithm omap_i2c_algo = {
> >  	.functionality	= omap_i2c_func,
> >  };
> >  
> > +static const struct of_device_id omap_i2c_of_match[];
> >  static int __devinit
> >  omap_i2c_probe(struct platform_device *pdev)
> >  {
> > @@ -979,10 +984,15 @@ omap_i2c_probe(struct platform_device *pdev)
> >  	struct i2c_adapter	*adap;
> >  	struct resource		*mem, *irq, *ioarea;
> >  	struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data;
> > +	const struct of_device_id *match;
> >  	irq_handler_t isr;
> >  	int r;
> >  	u32 speed = 0;
> >  
> > +	match = of_match_device(omap_i2c_of_match, &pdev->dev);
> > +	if (!match)
> > +		dev_err(&pdev->dev, "DT: i2c device match not found.......\n");
> > +
> 
> This isn't an error.  It just mean that the device wasn't registered
> from the device tree, and it needs to get its configuration from
> pdata.
> 
> In fact, you don't even need this block since the driver never uses
> the match entry returned by of_match_device()

ok. I will remove this.
> 
> >  	/* NOTE: driver uses the static register mapping */
> >  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >  	if (!mem) {
> > @@ -1007,10 +1017,19 @@ omap_i2c_probe(struct platform_device *pdev)
> >  		r = -ENOMEM;
> >  		goto err_release_region;
> >  	}
> > -
> 
> Don't drop the empty line.
> 
> > +	/* I2C device without DT might use this */
> 
> No need for the comment.
ok
> 
> >  	if (pdata != NULL) {
> >  		speed = pdata->clkrate;
> >  		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
> > +	} else if (pdev->dev.of_node) {
> > +		const unsigned int *prop;
> > +		prop = of_get_property(pdev->dev.of_node,
> > +				"clock-frequency", NULL);
> > +		if (prop)
> > +			speed = be32_to_cpup(prop);
> > +		else
> > +			speed = 100;
> 
> There is a new function that makes this easier.  Do this instead:
> 
> 	speed = 100;
> 	if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", &prop)
> 		speed = prop / 1000000; /* speed in Hz, this might be wrong */
These patches got merged after posting this series. I will take care of it in
the next version.

BTW, I have posted seperate patch to use above API for code optimization.


> 
> > +		dev->set_mpu_wkup_lat = NULL;
> 
> dev is kzalloced, which means set_mpu_wkup_lat is already NULL.
> 
> >  	} else {
> >  		speed = 100;	/* Default speed */
> >  		dev->set_mpu_wkup_lat = NULL;
> > @@ -1045,6 +1064,7 @@ omap_i2c_probe(struct platform_device *pdev)
> >  
> >  	dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff;
> >  
> > +
> 
> Drop the unrelated whitespace change.
> 
> >  	if (dev->rev <= OMAP_I2C_REV_ON_3430)
> >  		dev->errata |= I2C_OMAP3_1P153;
> >  
> > @@ -1073,6 +1093,7 @@ omap_i2c_probe(struct platform_device *pdev)
> >  				       (1000 * speed / 8);
> >  	}
> >  
> > +
> 
> Ditto.
> 
> >  	/* reset ASAP, clearing any IRQs */
> >  	omap_i2c_init(dev);
> >  
> > @@ -1162,6 +1183,12 @@ static int omap_i2c_resume(struct device *dev)
> >  	return 0;
> >  }
> >  
> > +static const struct of_device_id omap_i2c_of_match[] = {
> > +	{.compatible = "ti,omap_i2c", },
> > +	{},
> > +}
> > +MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
> > +
> 
> This needs to be protected with #ifdef CONFIG_OF/#else/#endif.  Don't
> break non-dt builds.
> 

ok. Thanks.

-Manjunath

  reply	other threads:[~2011-07-07 17:13 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 10:07 [RFC PATCH 0/5] OMAP: I2C: Add device tree support G, Manjunath Kondaiah
2011-06-30 10:07 ` [RFC PATCH 1/5] OMAP3:I2C: Add device tree nodes for beagle board G, Manjunath Kondaiah
2011-06-30 14:27   ` Tony Lindgren
2011-06-30 14:27     ` Tony Lindgren
2011-07-06 18:49     ` Grant Likely
2011-07-06 18:49       ` Grant Likely
2011-07-06 18:55   ` Grant Likely
2011-07-06 18:55     ` Grant Likely
2011-07-06 23:26     ` Stephen Warren
2011-07-06 23:26       ` Stephen Warren
     [not found]       ` <74CDBE0F657A3D45AFBB94109FB122FF049E21C203-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-07-07  0:12         ` Grant Likely
2011-07-07  0:12           ` Grant Likely
     [not found]           ` <CACxGe6u8qq7FA7kFXbU5uCk6m_GA8GWLqsdjFCXN+NMJfFKxmA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-07-20 11:04             ` Shawn Guo
2011-07-20 11:04               ` Shawn Guo
     [not found]               ` <20110720110419.GA6999-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-07-20 18:55                 ` Grant Likely
2011-07-20 18:55                   ` Grant Likely
     [not found]                   ` <20110720185513.GI4642-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-07-20 22:33                     ` Shawn Guo
2011-07-20 22:33                       ` Shawn Guo
     [not found]                       ` <20110720223348.GH6999-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-07-20 23:14                         ` Grant Likely
2011-07-20 23:14                           ` Grant Likely
2011-06-30 10:07 ` [RFC PATCH 2/5] OMAP4:I2C: Add device tree nodes for panda board G, Manjunath Kondaiah
2011-07-06 18:57   ` Grant Likely
2011-07-06 18:57     ` Grant Likely
2011-07-07 16:59     ` G, Manjunath Kondaiah
2011-07-07 16:59       ` G, Manjunath Kondaiah
2011-06-30 10:07 ` [RFC PATCH 3/5] OMAP3: Beagle: Update beagle board file to use DT G, Manjunath Kondaiah
2011-07-06 19:00   ` Grant Likely
2011-07-06 19:00     ` Grant Likely
2011-07-07 17:04     ` G, Manjunath Kondaiah
2011-07-07 17:04       ` G, Manjunath Kondaiah
2011-06-30 10:07 ` [RFC PATCH 4/5] OMAP4: Panda: Update panda " G, Manjunath Kondaiah
2011-07-06 19:01   ` Grant Likely
2011-07-06 19:01     ` Grant Likely
2011-06-30 10:07 ` [RFC PATCH 5/5] OMAP: I2C: Convert I2C driver to use device tree G, Manjunath Kondaiah
2011-07-06 19:08   ` Grant Likely
2011-07-06 19:08     ` Grant Likely
2011-07-07 17:13     ` G, Manjunath Kondaiah [this message]
2011-07-07 17:13       ` G, Manjunath Kondaiah
2011-07-07 18:28       ` Grant Likely
2011-07-07 18:28         ` Grant Likely

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=20110707171349.GC3124@manju-desktop \
    --to=manjugk@ti.com \
    --cc=ben-linux@fluff.org \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    /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.