mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
i2c: imx_lpi2c: Replace hard-coded bus speed value with bus->speed_hz
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@ifm.com>
This commit is contained in:
parent
ed1842623f
commit
34c6731abe
1 changed files with 9 additions and 6 deletions
|
@ -19,7 +19,7 @@
|
||||||
#define LPI2C_NACK_TOUT_MS 1
|
#define LPI2C_NACK_TOUT_MS 1
|
||||||
#define LPI2C_TIMEOUT_MS 100
|
#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 */
|
/* Weak linked function for overridden by some SoC power function */
|
||||||
int __weak init_i2c_power(unsigned i2c_num)
|
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);
|
debug("i2c: start check busy bus: 0x%x\n", result);
|
||||||
|
|
||||||
/* Try to init the lpi2c then check the bus busy again */
|
/* 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);
|
result = imx_lpci2c_check_busy_bus(regs);
|
||||||
if (result) {
|
if (result) {
|
||||||
printf("i2c: Error check busy bus: 0x%x\n", 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bus_i2c_init(struct udevice *bus, int speed)
|
static int bus_i2c_init(struct udevice *bus)
|
||||||
{
|
{
|
||||||
u32 val;
|
u32 val;
|
||||||
int ret;
|
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_bus *i2c_bus = dev_get_priv(bus);
|
||||||
struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)(i2c_bus->base);
|
struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)(i2c_bus->base);
|
||||||
/* reset peripheral */
|
/* reset peripheral */
|
||||||
|
@ -388,13 +391,13 @@ static int imx_lpi2c_probe_chip(struct udevice *bus, u32 chip,
|
||||||
result = bus_i2c_start(bus, chip, 0);
|
result = bus_i2c_start(bus, chip, 0);
|
||||||
if (result) {
|
if (result) {
|
||||||
bus_i2c_stop(bus);
|
bus_i2c_stop(bus);
|
||||||
bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
|
bus_i2c_init(bus);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = bus_i2c_stop(bus);
|
result = bus_i2c_stop(bus);
|
||||||
if (result)
|
if (result)
|
||||||
bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
|
bus_i2c_init(bus);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +492,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bus_i2c_init(bus, I2C_SPEED_STANDARD_RATE);
|
ret = bus_i2c_init(bus);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue