[PATCH v3 2/3] i2c: imx_lpi2c: Replace hard-coded bus speed value with bus->speed_hz
fedorross at gmail.com
fedorross at gmail.com
Wed Aug 7 16:08:00 CEST 2024
From: Fedor Ross <fedor.ross at ifm.com>
Instead of using the hard-coded bus speed value I2C_SPEED_STANDARD_RATE,
use the actual configured bus speed. This way the bus speed doesn't
change suddenly after calling the imx_lpi2c_probe_chip() function for
example.
Signed-off-by: Fedor Ross <fedor.ross at ifm.com>
---
Cc: Heiko Schocher <hs at denx.de>
Cc: Tom Rini <trini at konsulko.com>
Cc: Marek Vasut <marex at denx.de>
---
Changes in v3:
- none
Changes in v2:
- Add additional '---' below SoB line to separate Cc list. This way it
does not get included in the commit message when the patch is applied.
- Drop the second parameter of bus_i2c_init().
drivers/i2c/imx_lpi2c.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c
index 3c43f61d819..54db6fa863f 100644
--- a/drivers/i2c/imx_lpi2c.c
+++ b/drivers/i2c/imx_lpi2c.c
@@ -19,7 +19,7 @@
#define LPI2C_NACK_TOUT_MS 1
#define LPI2C_TIMEOUT_MS 100
-static int bus_i2c_init(struct udevice *bus, int speed);
+static int bus_i2c_init(struct udevice *bus);
/* Weak linked function for overridden by some SoC power function */
int __weak init_i2c_power(unsigned i2c_num)
@@ -172,7 +172,7 @@ static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir)
debug("i2c: start check busy bus: 0x%x\n", result);
/* Try to init the lpi2c then check the bus busy again */
- bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ bus_i2c_init(bus);
result = imx_lpci2c_check_busy_bus(regs);
if (result) {
printf("i2c: Error check busy bus: 0x%x\n", result);
@@ -344,11 +344,14 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
return 0;
}
-static int bus_i2c_init(struct udevice *bus, int speed)
+static int bus_i2c_init(struct udevice *bus)
{
u32 val;
int ret;
+ struct dm_i2c_bus *i2c = dev_get_uclass_priv(bus);
+ int speed = i2c->speed_hz;
+
struct imx_lpi2c_bus *i2c_bus = dev_get_priv(bus);
struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)(i2c_bus->base);
/* reset peripheral */
@@ -388,13 +391,13 @@ static int imx_lpi2c_probe_chip(struct udevice *bus, u32 chip,
result = bus_i2c_start(bus, chip, 0);
if (result) {
bus_i2c_stop(bus);
- bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ bus_i2c_init(bus);
return result;
}
result = bus_i2c_stop(bus);
if (result)
- bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ bus_i2c_init(bus);
return result;
}
@@ -489,7 +492,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
return ret;
}
- ret = bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
+ ret = bus_i2c_init(bus);
if (ret < 0)
return ret;
--
2.34.1
More information about the U-Boot
mailing list