mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
i2c: Make deblock delay and SCL clock configurable
Make the delay between SCL line changes and the number of SCL clock changes configurable as a parameter of the deblock function. No functional change. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
e24f0a39d0
commit
1f746a2c82
1 changed files with 11 additions and 10 deletions
|
@ -502,34 +502,35 @@ static int i2c_gpio_get_pin(struct gpio_desc *pin)
|
|||
}
|
||||
|
||||
static int i2c_deblock_gpio_loop(struct gpio_desc *sda_pin,
|
||||
struct gpio_desc *scl_pin)
|
||||
struct gpio_desc *scl_pin,
|
||||
unsigned int scl_count,
|
||||
unsigned int delay)
|
||||
{
|
||||
int counter = 9;
|
||||
int ret = 0;
|
||||
|
||||
i2c_gpio_set_pin(sda_pin, 1);
|
||||
i2c_gpio_set_pin(scl_pin, 1);
|
||||
udelay(5);
|
||||
udelay(delay);
|
||||
|
||||
/* Toggle SCL until slave release SDA */
|
||||
while (counter-- >= 0) {
|
||||
while (scl_count-- >= 0) {
|
||||
i2c_gpio_set_pin(scl_pin, 1);
|
||||
udelay(5);
|
||||
udelay(delay);
|
||||
i2c_gpio_set_pin(scl_pin, 0);
|
||||
udelay(5);
|
||||
udelay(delay);
|
||||
if (i2c_gpio_get_pin(sda_pin))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Then, send I2C stop */
|
||||
i2c_gpio_set_pin(sda_pin, 0);
|
||||
udelay(5);
|
||||
udelay(delay);
|
||||
|
||||
i2c_gpio_set_pin(scl_pin, 1);
|
||||
udelay(5);
|
||||
udelay(delay);
|
||||
|
||||
i2c_gpio_set_pin(sda_pin, 1);
|
||||
udelay(5);
|
||||
udelay(delay);
|
||||
|
||||
if (!i2c_gpio_get_pin(sda_pin) || !i2c_gpio_get_pin(scl_pin))
|
||||
ret = -EREMOTEIO;
|
||||
|
@ -561,7 +562,7 @@ static int i2c_deblock_gpio(struct udevice *bus)
|
|||
goto out_no_pinctrl;
|
||||
}
|
||||
|
||||
ret0 = i2c_deblock_gpio_loop(&gpios[PIN_SDA], &gpios[PIN_SCL]);
|
||||
ret0 = i2c_deblock_gpio_loop(&gpios[PIN_SDA], &gpios[PIN_SCL], 9, 5);
|
||||
|
||||
ret = pinctrl_select_state(bus, "default");
|
||||
if (ret) {
|
||||
|
|
Loading…
Reference in a new issue