i2c: s3c2410: Add support for pinctrl
This patch adds support for pin configuration using pinctrl subsystem to the i2c-s3c2410 driver. Signed-off-by: Tomasz Figa <t.figa@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
This commit is contained in:
parent
a72ad456bb
commit
2693ac6988
|
@ -13,11 +13,17 @@ Required properties:
|
||||||
- interrupts: interrupt number to the cpu.
|
- interrupts: interrupt number to the cpu.
|
||||||
- samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
|
- samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
|
||||||
|
|
||||||
|
Required for all cases except "samsung,s3c2440-hdmiphy-i2c":
|
||||||
|
- Samsung GPIO variant (deprecated):
|
||||||
|
- gpios: The order of the gpios should be the following: <SDA, SCL>.
|
||||||
|
The gpio specifier depends on the gpio controller. Required in all
|
||||||
|
cases except for "samsung,s3c2440-hdmiphy-i2c" whose input/output
|
||||||
|
lines are permanently wired to the respective clienta
|
||||||
|
- Pinctrl variant (preferred, if available):
|
||||||
|
- pinctrl-0: Pin control group to be used for this controller.
|
||||||
|
- pinctrl-names: Should contain only one value - "default".
|
||||||
|
|
||||||
Optional properties:
|
Optional properties:
|
||||||
- gpios: The order of the gpios should be the following: <SDA, SCL>.
|
|
||||||
The gpio specifier depends on the gpio controller. Required in all
|
|
||||||
cases except for "samsung,s3c2440-hdmiphy-i2c" whose input/output
|
|
||||||
lines are permanently wired to the respective client
|
|
||||||
- samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
|
- samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
|
||||||
specified, default value is 0.
|
specified, default value is 0.
|
||||||
- samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
|
- samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
|
||||||
|
@ -31,8 +37,14 @@ Example:
|
||||||
interrupts = <345>;
|
interrupts = <345>;
|
||||||
samsung,i2c-sda-delay = <100>;
|
samsung,i2c-sda-delay = <100>;
|
||||||
samsung,i2c-max-bus-freq = <100000>;
|
samsung,i2c-max-bus-freq = <100000>;
|
||||||
|
/* Samsung GPIO variant begins here */
|
||||||
gpios = <&gpd1 2 0 /* SDA */
|
gpios = <&gpd1 2 0 /* SDA */
|
||||||
&gpd1 3 0 /* SCL */>;
|
&gpd1 3 0 /* SCL */>;
|
||||||
|
/* Samsung GPIO variant ends here */
|
||||||
|
/* Pinctrl variant begins here */
|
||||||
|
pinctrl-0 = <&i2c3_bus>;
|
||||||
|
pinctrl-names = "default";
|
||||||
|
/* Pinctrl variant ends here */
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
#size-cells = <0>;
|
#size-cells = <0>;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/of_i2c.h>
|
#include <linux/of_i2c.h>
|
||||||
#include <linux/of_gpio.h>
|
#include <linux/of_gpio.h>
|
||||||
|
#include <linux/pinctrl/consumer.h>
|
||||||
|
|
||||||
#include <asm/irq.h>
|
#include <asm/irq.h>
|
||||||
|
|
||||||
|
@ -82,6 +83,7 @@ struct s3c24xx_i2c {
|
||||||
|
|
||||||
struct s3c2410_platform_i2c *pdata;
|
struct s3c2410_platform_i2c *pdata;
|
||||||
int gpios[2];
|
int gpios[2];
|
||||||
|
struct pinctrl *pctrl;
|
||||||
#ifdef CONFIG_CPU_FREQ
|
#ifdef CONFIG_CPU_FREQ
|
||||||
struct notifier_block freq_transition;
|
struct notifier_block freq_transition;
|
||||||
#endif
|
#endif
|
||||||
|
@ -860,9 +862,8 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
|
||||||
|
|
||||||
if (pdata->cfg_gpio)
|
if (pdata->cfg_gpio)
|
||||||
pdata->cfg_gpio(to_platform_device(i2c->dev));
|
pdata->cfg_gpio(to_platform_device(i2c->dev));
|
||||||
else
|
else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c))
|
||||||
if (s3c24xx_i2c_parse_dt_gpio(i2c))
|
return -EINVAL;
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* write slave address */
|
/* write slave address */
|
||||||
|
|
||||||
|
@ -1003,6 +1004,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
|
||||||
i2c->adap.algo_data = i2c;
|
i2c->adap.algo_data = i2c;
|
||||||
i2c->adap.dev.parent = &pdev->dev;
|
i2c->adap.dev.parent = &pdev->dev;
|
||||||
|
|
||||||
|
i2c->pctrl = devm_pinctrl_get_select_default(i2c->dev);
|
||||||
|
|
||||||
/* initialise the i2c controller */
|
/* initialise the i2c controller */
|
||||||
|
|
||||||
ret = s3c24xx_i2c_init(i2c);
|
ret = s3c24xx_i2c_init(i2c);
|
||||||
|
@ -1092,7 +1095,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
|
||||||
clk_disable_unprepare(i2c->clk);
|
clk_disable_unprepare(i2c->clk);
|
||||||
clk_put(i2c->clk);
|
clk_put(i2c->clk);
|
||||||
|
|
||||||
s3c24xx_i2c_dt_gpio_free(i2c);
|
if (pdev->dev.of_node && IS_ERR(i2c->pctrl))
|
||||||
|
s3c24xx_i2c_dt_gpio_free(i2c);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue