Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

I2C: xiic: Add OF binding support

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>

authored by

Lars-Peter Clausen and committed by
Wolfram Sang
3ac0b337 e7065e20

+40 -5
+22
Documentation/devicetree/bindings/i2c/xiic.txt
··· 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 + };
+18 -5
drivers/i2c/busses/i2c-xiic.c
··· 40 40 #include <linux/i2c-xiic.h> 41 41 #include <linux/io.h> 42 42 #include <linux/slab.h> 43 + #include <linux/of_i2c.h> 43 44 44 45 #define DRIVER_NAME "xiic-i2c" 45 46 ··· 706 705 goto resource_missing; 707 706 708 707 pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data; 709 - if (!pdata) 710 - return -EINVAL; 711 708 712 709 i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); 713 710 if (!i2c) ··· 729 730 i2c->adap = xiic_adapter; 730 731 i2c_set_adapdata(&i2c->adap, i2c); 731 732 i2c->adap.dev.parent = &pdev->dev; 733 + i2c->adap.dev.of_node = pdev->dev.of_node; 732 734 733 735 xiic_reinit(i2c); 734 736 ··· 748 748 goto add_adapter_failed; 749 749 } 750 750 751 - /* add in known devices to the bus */ 752 - for (i = 0; i < pdata->num_devices; i++) 753 - i2c_new_device(&i2c->adap, pdata->devices + i); 751 + if (pdata) { 752 + /* add in known devices to the bus */ 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 759 return 0; 756 760 ··· 799 795 return 0; 800 796 } 801 797 798 + #if defined(CONFIG_OF) 799 + static const struct of_device_id xiic_of_match[] __devinitconst = { 800 + { .compatible = "xlnx,xps-iic-2.00.a", }, 801 + {}, 802 + }; 803 + MODULE_DEVICE_TABLE(of, xiic_of_match); 804 + #endif 805 + 802 806 static struct platform_driver xiic_i2c_driver = { 803 807 .probe = xiic_i2c_probe, 804 808 .remove = __devexit_p(xiic_i2c_remove), 805 809 .driver = { 806 810 .owner = THIS_MODULE, 807 811 .name = DRIVER_NAME, 812 + .of_match_table = of_match_ptr(xiic_of_match), 808 813 }, 809 814 }; 810 815