diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-04-25 09:48:53 -0400 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2012-05-12 08:28:18 -0400 |
commit | 3ac0b3379307f9c9bd00beacbf02623ab127e334 (patch) | |
tree | 73ba925f16be3cdc1af6c2cc6257942be1c7dbfd /drivers/i2c | |
parent | e7065e20d9a6a8ee4a8b31ebe71d6c00a0f45354 (diff) |
I2C: xiic: Add OF binding support
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-xiic.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 2bded7647ef2..641d0e5e3303 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/i2c-xiic.h> | 40 | #include <linux/i2c-xiic.h> |
41 | #include <linux/io.h> | 41 | #include <linux/io.h> |
42 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
43 | #include <linux/of_i2c.h> | ||
43 | 44 | ||
44 | #define DRIVER_NAME "xiic-i2c" | 45 | #define DRIVER_NAME "xiic-i2c" |
45 | 46 | ||
@@ -705,8 +706,6 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev) | |||
705 | goto resource_missing; | 706 | goto resource_missing; |
706 | 707 | ||
707 | pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data; | 708 | pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data; |
708 | if (!pdata) | ||
709 | return -EINVAL; | ||
710 | 709 | ||
711 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); | 710 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); |
712 | if (!i2c) | 711 | if (!i2c) |
@@ -730,6 +729,7 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev) | |||
730 | i2c->adap = xiic_adapter; | 729 | i2c->adap = xiic_adapter; |
731 | i2c_set_adapdata(&i2c->adap, i2c); | 730 | i2c_set_adapdata(&i2c->adap, i2c); |
732 | i2c->adap.dev.parent = &pdev->dev; | 731 | i2c->adap.dev.parent = &pdev->dev; |
732 | i2c->adap.dev.of_node = pdev->dev.of_node; | ||
733 | 733 | ||
734 | xiic_reinit(i2c); | 734 | xiic_reinit(i2c); |
735 | 735 | ||
@@ -748,9 +748,13 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev) | |||
748 | goto add_adapter_failed; | 748 | goto add_adapter_failed; |
749 | } | 749 | } |
750 | 750 | ||
751 | /* add in known devices to the bus */ | 751 | if (pdata) { |
752 | for (i = 0; i < pdata->num_devices; i++) | 752 | /* add in known devices to the bus */ |
753 | i2c_new_device(&i2c->adap, pdata->devices + i); | 753 | for (i = 0; i < pdata->num_devices; i++) |
754 | i2c_new_device(&i2c->adap, pdata->devices + i); | ||
755 | } | ||
756 | |||
757 | of_i2c_register_devices(&i2c->adap); | ||
754 | 758 | ||
755 | return 0; | 759 | return 0; |
756 | 760 | ||
@@ -795,12 +799,21 @@ static int __devexit xiic_i2c_remove(struct platform_device* pdev) | |||
795 | return 0; | 799 | return 0; |
796 | } | 800 | } |
797 | 801 | ||
802 | #if defined(CONFIG_OF) | ||
803 | static const struct of_device_id xiic_of_match[] __devinitconst = { | ||
804 | { .compatible = "xlnx,xps-iic-2.00.a", }, | ||
805 | {}, | ||
806 | }; | ||
807 | MODULE_DEVICE_TABLE(of, xiic_of_match); | ||
808 | #endif | ||
809 | |||
798 | static struct platform_driver xiic_i2c_driver = { | 810 | static struct platform_driver xiic_i2c_driver = { |
799 | .probe = xiic_i2c_probe, | 811 | .probe = xiic_i2c_probe, |
800 | .remove = __devexit_p(xiic_i2c_remove), | 812 | .remove = __devexit_p(xiic_i2c_remove), |
801 | .driver = { | 813 | .driver = { |
802 | .owner = THIS_MODULE, | 814 | .owner = THIS_MODULE, |
803 | .name = DRIVER_NAME, | 815 | .name = DRIVER_NAME, |
816 | .of_match_table = of_match_ptr(xiic_of_match), | ||
804 | }, | 817 | }, |
805 | }; | 818 | }; |
806 | 819 | ||