summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-gpio.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-02-21 11:17:07 -0500
committerTom Rini <trini@konsulko.com>2021-02-21 11:17:07 -0500
commitb732c8780c3f7b47b00bd59e5f6ad7d6ec099d68 (patch)
tree2e4d72720d9254f7ba8be5a981368d77d92f91dc /drivers/i2c/i2c-gpio.c
parent72993e8e03845f82c3ccf7c72f205c9afd8da6d6 (diff)
parent2147a16983d17bcb0438607aa7760494afc27014 (diff)
Merge tag 'for-v2021.04' of https://gitlab.denx.de/u-boot/custodians/u-boot-i2c
i2c changes for v2021.04 new feature: - Allow disabling driver model for I2C in SPL fixes: - i2c-gpio: Fix GPIO output - at91: fix crash when using 'i2c probe'
Diffstat (limited to 'drivers/i2c/i2c-gpio.c')
-rw-r--r--drivers/i2c/i2c-gpio.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index 387f00b2cde..a301a4460b3 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -50,9 +50,10 @@ static void i2c_gpio_sda_set(struct i2c_gpio_bus *bus, int bit)
struct gpio_desc *sda = &bus->gpios[PIN_SDA];
if (bit)
- dm_gpio_set_dir_flags(sda, GPIOD_IS_IN);
+ sda->flags = (sda->flags & ~GPIOD_IS_OUT) | GPIOD_IS_IN;
else
- dm_gpio_set_dir_flags(sda, GPIOD_IS_OUT);
+ sda->flags = (sda->flags & (~GPIOD_IS_IN & ~GPIOD_IS_OUT_ACTIVE)) | GPIOD_IS_OUT;
+ dm_gpio_set_dir(sda);
}
static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit)
@@ -61,14 +62,16 @@ static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit)
int count = 0;
if (bit) {
- dm_gpio_set_dir_flags(scl, GPIOD_IS_IN);
+ scl->flags = (scl->flags & ~GPIOD_IS_OUT) | GPIOD_IS_IN;
+ dm_gpio_set_dir(scl);
while (!dm_gpio_get_value(scl) && count++ < 100000)
udelay(1);
if (!dm_gpio_get_value(scl))
pr_err("timeout waiting on slave to release scl\n");
} else {
- dm_gpio_set_dir_flags(scl, GPIOD_IS_OUT);
+ scl->flags = (scl->flags & (~GPIOD_IS_IN & ~GPIOD_IS_OUT_ACTIVE)) | GPIOD_IS_OUT;
+ dm_gpio_set_dir(scl);
}
}
@@ -76,11 +79,11 @@ static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit)
static void i2c_gpio_scl_set_output_only(struct i2c_gpio_bus *bus, int bit)
{
struct gpio_desc *scl = &bus->gpios[PIN_SCL];
- ulong flags = GPIOD_IS_OUT;
+ scl->flags = (scl->flags & (~GPIOD_IS_IN & ~GPIOD_IS_OUT_ACTIVE)) | GPIOD_IS_OUT;
if (bit)
- flags |= GPIOD_IS_OUT_ACTIVE;
- dm_gpio_set_dir_flags(scl, flags);
+ scl->flags |= GPIOD_IS_OUT_ACTIVE;
+ dm_gpio_set_dir(scl);
}
static void i2c_gpio_write_bit(struct i2c_gpio_bus *bus, int delay, uchar bit)