diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-at91.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 78bcad031d6..aa59a254be2 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -24,6 +24,9 @@ | |||
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/of.h> | ||
28 | #include <linux/of_device.h> | ||
29 | #include <linux/of_i2c.h> | ||
27 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
28 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
29 | 32 | ||
@@ -347,6 +350,12 @@ static struct at91_twi_pdata at91sam9g10_config = { | |||
347 | .has_unre_flag = false, | 350 | .has_unre_flag = false, |
348 | }; | 351 | }; |
349 | 352 | ||
353 | static struct at91_twi_pdata at91sam9x5_config = { | ||
354 | .clk_max_div = 7, | ||
355 | .clk_offset = 4, | ||
356 | .has_unre_flag = false, | ||
357 | }; | ||
358 | |||
350 | static const struct platform_device_id at91_twi_devtypes[] = { | 359 | static const struct platform_device_id at91_twi_devtypes[] = { |
351 | { | 360 | { |
352 | .name = "i2c-at91rm9200", | 361 | .name = "i2c-at91rm9200", |
@@ -368,6 +377,42 @@ static const struct platform_device_id at91_twi_devtypes[] = { | |||
368 | } | 377 | } |
369 | }; | 378 | }; |
370 | 379 | ||
380 | #if defined(CONFIG_OF) | ||
381 | static const struct of_device_id atmel_twi_dt_ids[] = { | ||
382 | { | ||
383 | .compatible = "atmel,at91sam9260-i2c", | ||
384 | .data = &at91sam9260_config, | ||
385 | } , { | ||
386 | .compatible = "atmel,at91sam9g20-i2c", | ||
387 | .data = &at91sam9g20_config, | ||
388 | } , { | ||
389 | .compatible = "atmel,at91sam9g10-i2c", | ||
390 | .data = &at91sam9g10_config, | ||
391 | }, { | ||
392 | .compatible = "atmel,at91sam9x5-i2c", | ||
393 | .data = &at91sam9x5_config, | ||
394 | }, { | ||
395 | /* sentinel */ | ||
396 | } | ||
397 | }; | ||
398 | MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids); | ||
399 | #else | ||
400 | #define atmel_twi_dt_ids NULL | ||
401 | #endif | ||
402 | |||
403 | static struct at91_twi_pdata * __devinit at91_twi_get_driver_data( | ||
404 | struct platform_device *pdev) | ||
405 | { | ||
406 | if (pdev->dev.of_node) { | ||
407 | const struct of_device_id *match; | ||
408 | match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node); | ||
409 | if (!match) | ||
410 | return NULL; | ||
411 | return match->data; | ||
412 | } | ||
413 | return (struct at91_twi_pdata *) platform_get_device_id(pdev)->driver_data; | ||
414 | } | ||
415 | |||
371 | static int __devinit at91_twi_probe(struct platform_device *pdev) | 416 | static int __devinit at91_twi_probe(struct platform_device *pdev) |
372 | { | 417 | { |
373 | struct at91_twi_dev *dev; | 418 | struct at91_twi_dev *dev; |
@@ -423,6 +468,7 @@ static int __devinit at91_twi_probe(struct platform_device *pdev) | |||
423 | dev->adapter.dev.parent = dev->dev; | 468 | dev->adapter.dev.parent = dev->dev; |
424 | dev->adapter.nr = pdev->id; | 469 | dev->adapter.nr = pdev->id; |
425 | dev->adapter.timeout = AT91_I2C_TIMEOUT; | 470 | dev->adapter.timeout = AT91_I2C_TIMEOUT; |
471 | dev->adapter.dev.of_node = pdev->dev.of_node; | ||
426 | 472 | ||
427 | rc = i2c_add_numbered_adapter(&dev->adapter); | 473 | rc = i2c_add_numbered_adapter(&dev->adapter); |
428 | if (rc) { | 474 | if (rc) { |
@@ -432,6 +478,8 @@ static int __devinit at91_twi_probe(struct platform_device *pdev) | |||
432 | return rc; | 478 | return rc; |
433 | } | 479 | } |
434 | 480 | ||
481 | of_i2c_register_devices(&dev->adapter); | ||
482 | |||
435 | dev_info(dev->dev, "AT91 i2c bus driver.\n"); | 483 | dev_info(dev->dev, "AT91 i2c bus driver.\n"); |
436 | return 0; | 484 | return 0; |
437 | } | 485 | } |
@@ -482,6 +530,7 @@ static struct platform_driver at91_twi_driver = { | |||
482 | .driver = { | 530 | .driver = { |
483 | .name = "at91_i2c", | 531 | .name = "at91_i2c", |
484 | .owner = THIS_MODULE, | 532 | .owner = THIS_MODULE, |
533 | .of_match_table = atmel_twi_dt_ids, | ||
485 | .pm = at91_twi_pm_ops, | 534 | .pm = at91_twi_pm_ops, |
486 | }, | 535 | }, |
487 | }; | 536 | }; |