diff options
-rw-r--r-- | Documentation/devicetree/bindings/i2c/samsung-i2c.txt | 20 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 12 |
2 files changed, 24 insertions, 8 deletions
diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt index b6cb5a12c67..e9611ace879 100644 --- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt +++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt | |||
@@ -13,11 +13,17 @@ Required properties: | |||
13 | - interrupts: interrupt number to the cpu. | 13 | - interrupts: interrupt number to the cpu. |
14 | - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges. | 14 | - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges. |
15 | 15 | ||
16 | Required for all cases except "samsung,s3c2440-hdmiphy-i2c": | ||
17 | - Samsung GPIO variant (deprecated): | ||
18 | - gpios: The order of the gpios should be the following: <SDA, SCL>. | ||
19 | The gpio specifier depends on the gpio controller. Required in all | ||
20 | cases except for "samsung,s3c2440-hdmiphy-i2c" whose input/output | ||
21 | lines are permanently wired to the respective clienta | ||
22 | - Pinctrl variant (preferred, if available): | ||
23 | - pinctrl-0: Pin control group to be used for this controller. | ||
24 | - pinctrl-names: Should contain only one value - "default". | ||
25 | |||
16 | Optional properties: | 26 | Optional properties: |
17 | - gpios: The order of the gpios should be the following: <SDA, SCL>. | ||
18 | The gpio specifier depends on the gpio controller. Required in all | ||
19 | cases except for "samsung,s3c2440-hdmiphy-i2c" whose input/output | ||
20 | lines are permanently wired to the respective client | ||
21 | - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not | 27 | - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not |
22 | specified, default value is 0. | 28 | specified, default value is 0. |
23 | - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not | 29 | - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not |
@@ -31,8 +37,14 @@ Example: | |||
31 | interrupts = <345>; | 37 | interrupts = <345>; |
32 | samsung,i2c-sda-delay = <100>; | 38 | samsung,i2c-sda-delay = <100>; |
33 | samsung,i2c-max-bus-freq = <100000>; | 39 | samsung,i2c-max-bus-freq = <100000>; |
40 | /* Samsung GPIO variant begins here */ | ||
34 | gpios = <&gpd1 2 0 /* SDA */ | 41 | gpios = <&gpd1 2 0 /* SDA */ |
35 | &gpd1 3 0 /* SCL */>; | 42 | &gpd1 3 0 /* SCL */>; |
43 | /* Samsung GPIO variant ends here */ | ||
44 | /* Pinctrl variant begins here */ | ||
45 | pinctrl-0 = <&i2c3_bus>; | ||
46 | pinctrl-names = "default"; | ||
47 | /* Pinctrl variant ends here */ | ||
36 | #address-cells = <1>; | 48 | #address-cells = <1>; |
37 | #size-cells = <0>; | 49 | #size-cells = <0>; |
38 | 50 | ||
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index f82d11f9b8f..40e2d40bbdb 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/io.h> | 38 | #include <linux/io.h> |
39 | #include <linux/of_i2c.h> | 39 | #include <linux/of_i2c.h> |
40 | #include <linux/of_gpio.h> | 40 | #include <linux/of_gpio.h> |
41 | #include <linux/pinctrl/consumer.h> | ||
41 | 42 | ||
42 | #include <asm/irq.h> | 43 | #include <asm/irq.h> |
43 | 44 | ||
@@ -82,6 +83,7 @@ struct s3c24xx_i2c { | |||
82 | 83 | ||
83 | struct s3c2410_platform_i2c *pdata; | 84 | struct s3c2410_platform_i2c *pdata; |
84 | int gpios[2]; | 85 | int gpios[2]; |
86 | struct pinctrl *pctrl; | ||
85 | #ifdef CONFIG_CPU_FREQ | 87 | #ifdef CONFIG_CPU_FREQ |
86 | struct notifier_block freq_transition; | 88 | struct notifier_block freq_transition; |
87 | #endif | 89 | #endif |
@@ -860,9 +862,8 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) | |||
860 | 862 | ||
861 | if (pdata->cfg_gpio) | 863 | if (pdata->cfg_gpio) |
862 | pdata->cfg_gpio(to_platform_device(i2c->dev)); | 864 | pdata->cfg_gpio(to_platform_device(i2c->dev)); |
863 | else | 865 | else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) |
864 | if (s3c24xx_i2c_parse_dt_gpio(i2c)) | 866 | return -EINVAL; |
865 | return -EINVAL; | ||
866 | 867 | ||
867 | /* write slave address */ | 868 | /* write slave address */ |
868 | 869 | ||
@@ -1003,6 +1004,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1003 | i2c->adap.algo_data = i2c; | 1004 | i2c->adap.algo_data = i2c; |
1004 | i2c->adap.dev.parent = &pdev->dev; | 1005 | i2c->adap.dev.parent = &pdev->dev; |
1005 | 1006 | ||
1007 | i2c->pctrl = devm_pinctrl_get_select_default(i2c->dev); | ||
1008 | |||
1006 | /* initialise the i2c controller */ | 1009 | /* initialise the i2c controller */ |
1007 | 1010 | ||
1008 | ret = s3c24xx_i2c_init(i2c); | 1011 | ret = s3c24xx_i2c_init(i2c); |
@@ -1092,7 +1095,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) | |||
1092 | clk_disable_unprepare(i2c->clk); | 1095 | clk_disable_unprepare(i2c->clk); |
1093 | clk_put(i2c->clk); | 1096 | clk_put(i2c->clk); |
1094 | 1097 | ||
1095 | s3c24xx_i2c_dt_gpio_free(i2c); | 1098 | if (pdev->dev.of_node && IS_ERR(i2c->pctrl)) |
1099 | s3c24xx_i2c_dt_gpio_free(i2c); | ||
1096 | 1100 | ||
1097 | return 0; | 1101 | return 0; |
1098 | } | 1102 | } |