diff options
| -rw-r--r-- | Documentation/devicetree/bindings/i2c/xiic.txt | 22 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-xiic.c | 23 |
2 files changed, 40 insertions, 5 deletions
diff --git a/Documentation/devicetree/bindings/i2c/xiic.txt b/Documentation/devicetree/bindings/i2c/xiic.txt new file mode 100644 index 000000000000..ceabbe91ae44 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/xiic.txt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | Xilinx IIC controller: | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible : Must be "xlnx,xps-iic-2.00.a" | ||
| 5 | - reg : IIC register location and length | ||
| 6 | - interrupts : IIC controller unterrupt | ||
| 7 | - #address-cells = <1> | ||
| 8 | - #size-cells = <0> | ||
| 9 | |||
| 10 | Optional properties: | ||
| 11 | - Child nodes conforming to i2c bus binding | ||
| 12 | |||
| 13 | Example: | ||
| 14 | |||
| 15 | axi_iic_0: i2c@40800000 { | ||
| 16 | compatible = "xlnx,xps-iic-2.00.a"; | ||
| 17 | interrupts = < 1 2 >; | ||
| 18 | reg = < 0x40800000 0x10000 >; | ||
| 19 | |||
| 20 | #size-cells = <0>; | ||
| 21 | #address-cells = <1>; | ||
| 22 | }; | ||
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 | ||
