All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benoit Cousson <b-cousson@ti.com>
To: grant.likely@secretlab.ca, tony@atomide.com
Cc: linux-omap@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org, manjugk@ti.com,
	Benoit Cousson <b-cousson@ti.com>
Subject: [PATCH 02/13] i2c: OMAP: Add DT support for i2c controller
Date: Thu, 1 Sep 2011 19:21:18 +0200	[thread overview]
Message-ID: <1314897689-17791-3-git-send-email-b-cousson@ti.com> (raw)
In-Reply-To: <1314897689-17791-1-git-send-email-b-cousson@ti.com>

From: G, Manjunath Kondaiah <manjugk@ti.com>

Add initial DT support to retrieve the frequency using a
DT attribute instead of the pdata pointer if CONFIG_OF is enabled.

These changes will not affect non DT builds and existing functionality
is retained.

Signed-off-by: G, Manjunath Kondaiah <manjugk@ti.com>
[b-cousson@ti.com: fix the wrong freq calculation]
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 2a072ff..4052279 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -38,6 +38,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/of_i2c.h>
+#include <linux/of_device.h>
 #include <linux/slab.h>
 #include <linux/i2c-omap.h>
 #include <linux/pm_runtime.h>
@@ -972,6 +973,16 @@ static const struct i2c_algorithm omap_i2c_algo = {
 	.functionality	= omap_i2c_func,
 };
 
+#if defined(CONFIG_OF)
+static const struct of_device_id omap_i2c_of_match[] = {
+	{.compatible = "ti,omap-i2c", },
+	{},
+}
+MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
+#else
+#define omap_i2c_of_match NULL
+#endif
+
 static int __devinit
 omap_i2c_probe(struct platform_device *pdev)
 {
@@ -1008,12 +1019,17 @@ omap_i2c_probe(struct platform_device *pdev)
 		goto err_release_region;
 	}
 
+	speed = 100;	/* Default speed */
 	if (pdata != NULL) {
 		speed = pdata->clkrate;
 		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
-	} else {
-		speed = 100;	/* Default speed */
-		dev->set_mpu_wkup_lat = NULL;
+#if defined(CONFIG_OF)
+	} else if (pdev->dev.of_node) {
+		u32 prop;
+		if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency",
+					  &prop))
+			speed = prop / 1000; /* convert Hz into kHz */
+#endif
 	}
 
 	dev->speed = speed;
@@ -1178,6 +1194,7 @@ static struct platform_driver omap_i2c_driver = {
 		.name	= "omap_i2c",
 		.owner	= THIS_MODULE,
 		.pm	= OMAP_I2C_PM_OPS,
+		.of_match_table = omap_i2c_of_match,
 	},
 };
 
-- 
1.7.0.4


WARNING: multiple messages have this Message-ID (diff)
From: b-cousson@ti.com (Benoit Cousson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 02/13] i2c: OMAP: Add DT support for i2c controller
Date: Thu, 1 Sep 2011 19:21:18 +0200	[thread overview]
Message-ID: <1314897689-17791-3-git-send-email-b-cousson@ti.com> (raw)
In-Reply-To: <1314897689-17791-1-git-send-email-b-cousson@ti.com>

From: G, Manjunath Kondaiah <manjugk@ti.com>

Add initial DT support to retrieve the frequency using a
DT attribute instead of the pdata pointer if CONFIG_OF is enabled.

These changes will not affect non DT builds and existing functionality
is retained.

Signed-off-by: G, Manjunath Kondaiah <manjugk@ti.com>
[b-cousson at ti.com: fix the wrong freq calculation]
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
---
 drivers/i2c/busses/i2c-omap.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 2a072ff..4052279 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -38,6 +38,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/of_i2c.h>
+#include <linux/of_device.h>
 #include <linux/slab.h>
 #include <linux/i2c-omap.h>
 #include <linux/pm_runtime.h>
@@ -972,6 +973,16 @@ static const struct i2c_algorithm omap_i2c_algo = {
 	.functionality	= omap_i2c_func,
 };
 
+#if defined(CONFIG_OF)
+static const struct of_device_id omap_i2c_of_match[] = {
+	{.compatible = "ti,omap-i2c", },
+	{},
+}
+MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
+#else
+#define omap_i2c_of_match NULL
+#endif
+
 static int __devinit
 omap_i2c_probe(struct platform_device *pdev)
 {
@@ -1008,12 +1019,17 @@ omap_i2c_probe(struct platform_device *pdev)
 		goto err_release_region;
 	}
 
+	speed = 100;	/* Default speed */
 	if (pdata != NULL) {
 		speed = pdata->clkrate;
 		dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
-	} else {
-		speed = 100;	/* Default speed */
-		dev->set_mpu_wkup_lat = NULL;
+#if defined(CONFIG_OF)
+	} else if (pdev->dev.of_node) {
+		u32 prop;
+		if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency",
+					  &prop))
+			speed = prop / 1000; /* convert Hz into kHz */
+#endif
 	}
 
 	dev->speed = speed;
@@ -1178,6 +1194,7 @@ static struct platform_driver omap_i2c_driver = {
 		.name	= "omap_i2c",
 		.owner	= THIS_MODULE,
 		.pm	= OMAP_I2C_PM_OPS,
+		.of_match_table = omap_i2c_of_match,
 	},
 };
 
-- 
1.7.0.4

  parent reply	other threads:[~2011-09-01 17:21 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 17:21 [PATCH 00/13] OMAP4: Add DT support for i2c and twl6030 Benoit Cousson
2011-09-01 17:21 ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 01/13] irq: Add stub for none DT build in irqdomain.h Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` Benoit Cousson [this message]
2011-09-01 17:21   ` [PATCH 02/13] i2c: OMAP: Add DT support for i2c controller Benoit Cousson
2011-09-01 17:21 ` [PATCH 03/13] documentation/dt: Add OMAP i2c bindings documentation Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 04/13] mfd: twl-core: Add initial DT support for twl4030/twl6030 Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 18:27   ` Arnd Bergmann
2011-09-01 18:27     ` Arnd Bergmann
2011-09-05 16:05     ` Cousson, Benoit
2011-09-05 16:05       ` Cousson, Benoit
2011-09-01 17:21 ` [PATCH 05/13] documentation/dt: Add TWL4030 and TWL6030 bindings Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 06/13] arm/dts: OMAP4: Add i2c controller nodes Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 07/13] arm/dts: omap4-sdp: Set clock freq for i2c controllers Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 08/13] arm/dts: omap4-panda: " Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 09/13] arm/dts: omap4-sdp: Add twl6030 node Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 10/13] arm/dts: omap4-panda: " Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 11/13] OMAP4: board-dt: Remove static i2c init Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 12/13] arm/dts: omap4-sdp: Add i2c3 & i2c4 devices Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 17:21 ` [PATCH 13/13] arm/dts: omap4-panda: Add EEPROM entry in i2c3 Benoit Cousson
2011-09-01 17:21   ` Benoit Cousson
2011-09-01 19:14 ` [PATCH 00/13] OMAP4: Add DT support for i2c and twl6030 Arnd Bergmann
2011-09-01 19:14   ` Arnd Bergmann

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=1314897689-17791-3-git-send-email-b-cousson@ti.com \
    --to=b-cousson@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=manjugk@ti.com \
    --cc=tony@atomide.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 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.