mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] Add device tree support of i2c Atmel driver
@ 2014-08-01 13:22 Raphaël Poggi
  2014-08-01 13:22 ` [PATCH 1/2] i2c: at91: add support of device tree Raphaël Poggi
  2014-08-01 13:22 ` [PATCH 2/2] at91sam9g45: clock: add i2c clocks Raphaël Poggi
  0 siblings, 2 replies; 3+ messages in thread
From: Raphaël Poggi @ 2014-08-01 13:22 UTC (permalink / raw)
  To: barebox

This patcheset adds the device tree support for i2c Atmel driver and the corresping clocks
for the at91sam9g45 device.

Raphaël Poggi (2) :
	(1) i2c: at91: add support of device tree
	(2) at91sam9g45: clock: add i2c clocks

arch/arm/mach-at91/at91sam9g45.c |    4 +++
drivers/i2c/busses/i2c-at91.c    |   60 +++++++++++++++++++++++++++++++++-----
2 files changed, 56 insertions(+), 8 deletions(-)


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] i2c: at91: add support of device tree
  2014-08-01 13:22 [PATCH 0/2] Add device tree support of i2c Atmel driver Raphaël Poggi
@ 2014-08-01 13:22 ` Raphaël Poggi
  2014-08-01 13:22 ` [PATCH 2/2] at91sam9g45: clock: add i2c clocks Raphaël Poggi
  1 sibling, 0 replies; 3+ messages in thread
From: Raphaël Poggi @ 2014-08-01 13:22 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

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

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 4aa4e4e..944a8b3 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -373,20 +373,63 @@ 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 struct at91_twi_pdata *at91_twi_get_driver_data(struct device_d *dev)
+{
+    struct at91_twi_pdata *i2c_data = NULL;
+    int rc;
+
+    if (dev->device_node) {
+	const struct of_device_id *match;
+	match = of_match_node(at91_twi_dt_ids, dev->device_node);
+	if (!match)
+	    i2c_data = NULL;
+	else
+	    i2c_data = (struct at91_twi_pdata *)match->data;
+    }
+    else {
+	rc = dev_get_drvdata(dev, (unsigned long *)&i2c_data);
+	if (rc)
+	    i2c_data = NULL;
+    }
+
+    return i2c_data;
+}
+
 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)
-		goto out_free;
-
-	i2c_at91->pdata = i2c_data;
+	i2c_at91->pdata = at91_twi_get_driver_data(dev);
+	if (!i2c_at91->pdata)
+	    goto out_free;
 
 	i2c_at91->base = dev_request_mem_region(dev, 0);
 	if (!i2c_at91->base) {
@@ -395,7 +438,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;
@@ -435,6 +478,7 @@ 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);
 
-- 
1.7.9.5


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] at91sam9g45: clock: add i2c clocks
  2014-08-01 13:22 [PATCH 0/2] Add device tree support of i2c Atmel driver Raphaël Poggi
  2014-08-01 13:22 ` [PATCH 1/2] i2c: at91: add support of device tree Raphaël Poggi
@ 2014-08-01 13:22 ` Raphaël Poggi
  1 sibling, 0 replies; 3+ messages in thread
From: Raphaël Poggi @ 2014-08-01 13:22 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

Add the device tree and non device tree at91 i2c clocks.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 arch/arm/mach-at91/at91sam9g45.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index f6031f0..d0f950c 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -192,6 +192,10 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci1", &mmc1_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "at91-twi0", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "at91-twi1", &twi1_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff84000.i2c", &twi0_clk),
+	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk),
 	CLKDEV_DEV_ID("at91rm9200-gpio0", &pioA_clk),
 	CLKDEV_DEV_ID("at91rm9200-gpio1", &pioB_clk),
 	CLKDEV_DEV_ID("at91rm9200-gpio2", &pioC_clk),
-- 
1.7.9.5


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-01 13:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01 13:22 [PATCH 0/2] Add device tree support of i2c Atmel driver Raphaël Poggi
2014-08-01 13:22 ` [PATCH 1/2] i2c: at91: add support of device tree Raphaël Poggi
2014-08-01 13:22 ` [PATCH 2/2] at91sam9g45: clock: add i2c clocks Raphaël Poggi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox