From: Lee Jones <lee.jones@linaro.org>
To: linux-arm-kernel@lists.infradead.org, arnd@arndb.de,
linus.walleij@stericsson.com, grant.likely@secretlab.ca,
cjb@laptop.org, broonie@opensource.wolfsonmicro.com,
sameo@linux.intel.com
Cc: Lee Jones <lee.jones@linaro.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 01/18] i2c: Add Device Tree support to the Nomadik I2C driver
Date: Thu, 17 May 2012 14:45:06 +0100 [thread overview]
Message-ID: <1337262323-27692-2-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1337262323-27692-1-git-send-email-lee.jones@linaro.org>
Here we move the i2c-nomadik's default settings into the driver
rather than specifying them from platform code. At the time of
this writing we only have one user, the u8500. As new users are
added, it is expected that they will be Device Tree compliant.
If this is the case, we will look up their initialisation values
by compatible entry, then apply them forthwith.
Cc: linux-i2c@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/i2c/busses/i2c-nomadik.c | 40 +++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 5267ab9..cd45563 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -23,6 +23,7 @@
#include <linux/io.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
+#include <linux/of_device.h>
#include <plat/i2c.h>
@@ -899,15 +900,51 @@ static const struct i2c_algorithm nmk_i2c_algo = {
.functionality = nmk_i2c_functionality
};
+static struct nmk_i2c_controller u8500_i2c = {
+ /*
+ * slave data setup time, which is
+ * 250 ns,100ns,10ns which is 14,6,2
+ * respectively for a 48 Mhz
+ * i2c clock
+ */
+ .slsu = 0xe,
+ /* Tx FIFO threshold */
+ .tft = 1,
+ /* Rx FIFO threshold */
+ .rft = 8,
+ /* std. mode operation */
+ .clk_freq = 100000,
+ /* Slave response timeout(ms) */
+ .timeout = 200,
+ .sm = I2C_FREQ_MODE_FAST,
+};
+
+
+static const struct of_device_id nmk_gpio_match[] = {
+ { .compatible = "st,nomadik-i2c", .data = &u8500_i2c, },
+ {}
+};
+
static int __devinit nmk_i2c_probe(struct platform_device *pdev)
{
int ret = 0;
struct resource *res;
- struct nmk_i2c_controller *pdata =
+ const struct nmk_i2c_controller *pdata =
pdev->dev.platform_data;
+ const struct of_device_id *of_id =
+ of_match_device(nmk_gpio_match, &pdev->dev);
struct nmk_i2c_dev *dev;
struct i2c_adapter *adap;
+ if (!pdata) {
+ if (of_id && of_id->data)
+ /* Looks like we're booting via Device Tree. */
+ pdata = of_id->data;
+ else
+ /* No i2c configuration found, using the default. */
+ pdata = &u8500_i2c;
+ }
+
dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
if (!dev) {
dev_err(&pdev->dev, "cannot allocate memory\n");
@@ -1044,6 +1081,7 @@ static struct platform_driver nmk_i2c_driver = {
.owner = THIS_MODULE,
.name = DRIVER_NAME,
.pm = &nmk_i2c_pm,
+ .of_match_table = nmk_gpio_match,
},
.probe = nmk_i2c_probe,
.remove = __devexit_p(nmk_i2c_remove),
--
1.7.9.5
next parent reply other threads:[~2012-05-17 13:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1337262323-27692-1-git-send-email-lee.jones@linaro.org>
2012-05-17 13:45 ` Lee Jones [this message]
2012-05-20 20:53 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 09/18] regulator: ab8500: Split up probe() into manageable pieces Lee Jones
2012-05-18 7:36 ` Mark Brown
2012-05-18 7:53 ` Lee Jones
2012-05-20 21:15 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 11/18] regulator: Enable the ab8500 for Device Tree Lee Jones
2012-05-18 7:36 ` Mark Brown
2012-05-18 7:52 ` Lee Jones
2012-05-20 21:14 ` Linus Walleij
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=1337262323-27692-2-git-send-email-lee.jones@linaro.org \
--to=lee.jones@linaro.org \
--cc=arnd@arndb.de \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=cjb@laptop.org \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@stericsson.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.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
all inboxes | Powered by JetHome®