Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 333371
b: refs/heads/master
c: 70d46a2
h: refs/heads/master
i:
  333369: 5a61377
  333367: 1f72053
v: v3
  • Loading branch information
Ludovic Desroches authored and Wolfram Sang committed Sep 12, 2012
1 parent 53bd483 commit af4c8b8
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 94e734655fbe294c50d304547cae033e87ec229e
refs/heads/master: 70d46a241ed3bb0d1bb2bc15720b6f7c215c37f5
30 changes: 30 additions & 0 deletions trunk/Documentation/devicetree/bindings/i2c/atmel-i2c.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
I2C for Atmel platforms

Required properties :
- compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
"atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c"
or "atmel,at91sam9x5-i2c"
- reg: physical base address of the controller and length of memory mapped
region.
- interrupts: interrupt number to the cpu.
- #address-cells = <1>;
- #size-cells = <0>;

Optional properties:
- Child nodes conforming to i2c bus binding

Examples :

i2c0: i2c@fff84000 {
compatible = "atmel,at91sam9g20-i2c";
reg = <0xfff84000 0x100>;
interrupts = <12 4 6>;
#address-cells = <1>;
#size-cells = <0>;

24c512@50 {
compatible = "24c512";
reg = <0x50>;
pagesize = <128>;
}
}
49 changes: 49 additions & 0 deletions trunk/drivers/i2c/busses/i2c-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_i2c.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

Expand Down Expand Up @@ -347,6 +350,12 @@ static struct at91_twi_pdata at91sam9g10_config = {
.has_unre_flag = false,
};

static struct at91_twi_pdata at91sam9x5_config = {
.clk_max_div = 7,
.clk_offset = 4,
.has_unre_flag = false,
};

static const struct platform_device_id at91_twi_devtypes[] = {
{
.name = "i2c-at91rm9200",
Expand All @@ -368,6 +377,42 @@ static const struct platform_device_id at91_twi_devtypes[] = {
}
};

#if defined(CONFIG_OF)
static const struct of_device_id atmel_twi_dt_ids[] = {
{
.compatible = "atmel,at91sam9260-i2c",
.data = &at91sam9260_config,
} , {
.compatible = "atmel,at91sam9g20-i2c",
.data = &at91sam9g20_config,
} , {
.compatible = "atmel,at91sam9g10-i2c",
.data = &at91sam9g10_config,
}, {
.compatible = "atmel,at91sam9x5-i2c",
.data = &at91sam9x5_config,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
#else
#define atmel_twi_dt_ids NULL
#endif

static struct at91_twi_pdata * __devinit at91_twi_get_driver_data(
struct platform_device *pdev)
{
if (pdev->dev.of_node) {
const struct of_device_id *match;
match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node);
if (!match)
return NULL;
return match->data;
}
return (struct at91_twi_pdata *) platform_get_device_id(pdev)->driver_data;
}

static int __devinit at91_twi_probe(struct platform_device *pdev)
{
struct at91_twi_dev *dev;
Expand Down Expand Up @@ -423,6 +468,7 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
dev->adapter.dev.parent = dev->dev;
dev->adapter.nr = pdev->id;
dev->adapter.timeout = AT91_I2C_TIMEOUT;
dev->adapter.dev.of_node = pdev->dev.of_node;

rc = i2c_add_numbered_adapter(&dev->adapter);
if (rc) {
Expand All @@ -432,6 +478,8 @@ static int __devinit at91_twi_probe(struct platform_device *pdev)
return rc;
}

of_i2c_register_devices(&dev->adapter);

dev_info(dev->dev, "AT91 i2c bus driver.\n");
return 0;
}
Expand Down Expand Up @@ -482,6 +530,7 @@ static struct platform_driver at91_twi_driver = {
.driver = {
.name = "at91_i2c",
.owner = THIS_MODULE,
.of_match_table = atmel_twi_dt_ids,
.pm = at91_twi_pm_ops,
},
};
Expand Down

0 comments on commit af4c8b8

Please sign in to comment.