mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Raphaël Poggi" <poggi.raph@gmail.com>
To: barebox@lists.infradead.org
Cc: "Raphaël Poggi" <poggi.raph@gmail.com>
Subject: [PATCH] i2c: at91: add support of device tree
Date: Wed, 24 Sep 2014 14:57:04 +0200	[thread overview]
Message-ID: <1411563425-28463-3-git-send-email-poggi.raph@gmail.com> (raw)
In-Reply-To: <1411563425-28463-1-git-send-email-poggi.raph@gmail.com>

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/i2c/busses/i2c-at91.c | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 9490822..a2236ed 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -376,18 +376,44 @@ static struct platform_device_id at91_twi_devtypes[] = {
 	}
 };
 
+static struct of_device_id at91_twi_dt_ids[] = {
+	{
+		.compatible = "atmel,at91rm9200-i2c",
+		.data = (unsigned long) &at91rm9200_config,
+	} , {
+		.compatible = "atmel,at91sam9260-i2c",
+		.data = (unsigned long) &at91sam9260_config,
+	} , {
+		.compatible = "atmel,at91sam9261-i2c",
+		.data = (unsigned long) &at91sam9261_config,
+	} , {
+		.compatible = "atmel,at91sam9g20-i2c",
+		.data = (unsigned long) &at91sam9g20_config,
+	} , {
+		.compatible = "atmel,at91sam9g10-i2c",
+		.data = (unsigned long) &at91sam9g10_config,
+	}, {
+		.compatible = "atmel,at91sam9x5-i2c",
+		.data = (unsigned long) &at91sam9x5_config,
+	}, {
+		/* sentinel */
+	}
+};
+
 static int at91_twi_probe(struct device_d *dev)
 {
 	struct at91_twi_dev *i2c_at91;
 	struct at91_twi_pdata *i2c_data;
-	int rc;
+	int rc = 0;
 	u32 bus_clk_rate;
 
 	i2c_at91 = xzalloc(sizeof(struct at91_twi_dev));
 
 	rc = dev_get_drvdata(dev, (unsigned long *)&i2c_data);
-	if (rc)
+	if (rc < 0) {
+		dev_err(dev, "failed to retrieve driver data\n");
 		goto out_free;
+	}
 
 	i2c_at91->pdata = i2c_data;
 
@@ -398,7 +424,7 @@ static int at91_twi_probe(struct device_d *dev)
 		goto out_free;
 	}
 
-	i2c_at91->clk = clk_get(dev, "twi_clk");
+	i2c_at91->clk = clk_get(dev, NULL);
 	if (IS_ERR(i2c_at91->clk)) {
 		dev_err(dev, "no clock defined\n");
 		rc = -ENODEV;
@@ -427,17 +453,18 @@ static int at91_twi_probe(struct device_d *dev)
 	return 0;
 
 out_adap_fail:
-    clk_disable(i2c_at91->clk);
-    clk_put(i2c_at91->clk);
+	clk_disable(i2c_at91->clk);
+	clk_put(i2c_at91->clk);
 out_free:
-    kfree(i2c_at91);
-    return rc;
+	kfree(i2c_at91);
+	return rc;
 }
 
 static struct driver_d at91_twi_driver = {
 	.name		= "at91-twi",
 	.probe		= at91_twi_probe,
 	.id_table	= at91_twi_devtypes,
+	.of_compatible	= DRV_OF_COMPAT(at91_twi_dt_ids),
 };
 device_platform_driver(at91_twi_driver);
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-09-24 12:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 12:57 [PATCH] i2c: at91: fix coding style issue Raphaël Poggi
2014-09-24 12:57 ` [PATCH] i2c: at91: add at91sam9x5 config Raphaël Poggi
2014-09-24 12:57 ` Raphaël Poggi [this message]
2014-09-24 12:57 ` [PATCH] I2C: at91: fix the method for interrupt Raphaël Poggi
2014-09-25  6:11 ` [PATCH] i2c: at91: fix coding style issue Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2014-09-17 15:00 [PATCH] i2c: at91: add support of device tree Raphaël Poggi
2014-09-18  6:27 ` Sascha Hauer

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=1411563425-28463-3-git-send-email-poggi.raph@gmail.com \
    --to=poggi.raph@gmail.com \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox