aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini2023-04-11 09:29:28 -0400
committerTom Rini2023-04-11 09:29:28 -0400
commit9e804638bfe2693a908abf066ff66c251572afa7 (patch)
tree20a1953649fdcc25acd2eb5bbb2aecf263d7d025 /drivers
parent11c25c6df0b56ee7eee2c4ddc7f075880daeb8c7 (diff)
parent5cf008637221ad3b4d4ecdc2befca19b2bdab53d (diff)
Merge tag 'for-v2023-07-rc1' of https://source.denx.de/u-boot/custodians/u-boot-i2c
i2c updates for v2023-07-rc1 - designware_i2c: remove apparently redundant read of 'i2c, speeds' DT property from Rasmus Villemoes - fix: correct I2C deblock logic from Haibo Chen - imx_lpi2c: Fix misuse the IS_ENABLED for DM clock from Ye Li - m68k: convert to DM from Angelo Dureghello
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/designware_i2c_pci.c14
-rw-r--r--drivers/i2c/fsl_i2c.c16
-rw-r--r--drivers/i2c/i2c-uclass.c4
-rw-r--r--drivers/i2c/imx_lpi2c.c4
4 files changed, 13 insertions, 25 deletions
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index 46c2545f214..28495a3f428 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -147,9 +147,7 @@ static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev,
{
struct dw_i2c_speed_config config;
char path[ACPI_PATH_MAX];
- u32 speeds[4];
uint speed;
- int size;
int ret;
/* If no device-tree node, ignore this since we assume it isn't used */
@@ -160,18 +158,6 @@ static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev,
if (ret)
return log_msg_ret("path", ret);
- size = dev_read_size(dev, "i2c,speeds");
- if (size < 0)
- return log_msg_ret("i2c,speeds", -EINVAL);
-
- size /= sizeof(u32);
- if (size > ARRAY_SIZE(speeds))
- return log_msg_ret("array", -E2BIG);
-
- ret = dev_read_u32_array(dev, "i2c,speeds", speeds, size);
- if (ret)
- return log_msg_ret("read", -E2BIG);
-
speed = dev_read_u32_default(dev, "clock-frequency", 100000);
acpigen_write_scope(ctx, path);
ret = dw_i2c_gen_speed_config(dev, speed, &config);
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index d312f35f044..d9d8ee81d2e 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -278,7 +278,8 @@ static void __i2c_init(const struct fsl_i2c_base *base, int speed, int
set_i2c_bus_speed(base, i2c_clk, speed);
writeb(slaveadd << 1, &base->adr);/* write slave address */
writeb(0x0, &base->sr); /* clear status register */
- writeb(I2C_CR_MEN, &base->cr); /* start I2C controller */
+ /* start I2C controller */
+ writeb(I2C_CR_MEN | I2C_CR_MIEN, &base->cr);
timeval = get_ticks();
while (readb(&base->sr) & I2C_SR_MBB) {
@@ -346,7 +347,7 @@ static int i2c_wait(const struct fsl_i2c_base *base, int write)
static int i2c_write_addr(const struct fsl_i2c_base *base, u8 dev,
u8 dir, int rsta)
{
- writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX
+ writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA | I2C_CR_MTX
| (rsta ? I2C_CR_RSTA : 0),
&base->cr);
@@ -378,7 +379,8 @@ static int __i2c_read_data(const struct fsl_i2c_base *base, u8 *data,
{
int i;
- writeb(I2C_CR_MEN | I2C_CR_MSTA | ((length == 1) ? I2C_CR_TXAK : 0),
+ writeb(I2C_CR_MEN | I2C_CR_MIEN |
+ I2C_CR_MSTA | ((length == 1) ? I2C_CR_TXAK : 0),
&base->cr);
/* dummy read */
@@ -390,13 +392,13 @@ static int __i2c_read_data(const struct fsl_i2c_base *base, u8 *data,
/* Generate ack on last next to last byte */
if (i == length - 2)
- writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_TXAK,
- &base->cr);
+ writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA |
+ I2C_CR_TXAK, &base->cr);
/* Do not generate stop on last byte */
if (i == length - 1)
- writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX,
- &base->cr);
+ writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA |
+ I2C_CR_MTX, &base->cr);
data[i] = readb(&base->dr);
}
diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 8d9a89ed890..8867a560bd8 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -508,13 +508,13 @@ static void i2c_gpio_set_pin(struct gpio_desc *pin, int bit)
dm_gpio_set_dir_flags(pin, GPIOD_IS_IN);
else
dm_gpio_set_dir_flags(pin, GPIOD_IS_OUT |
- GPIOD_ACTIVE_LOW |
GPIOD_IS_OUT_ACTIVE);
}
static int i2c_gpio_get_pin(struct gpio_desc *pin)
{
- return dm_gpio_get_value(pin);
+ /* DTS need config GPIO_ACTIVE_LOW */
+ return !dm_gpio_get_value(pin);
}
int i2c_deblock_gpio_loop(struct gpio_desc *sda_pin,
diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c
index 92c500327b4..ad9293c92e1 100644
--- a/drivers/i2c/imx_lpi2c.c
+++ b/drivers/i2c/imx_lpi2c.c
@@ -282,7 +282,7 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
bool mode;
int i;
- if (IS_ENABLED(CONFIG_CLK)) {
+ if (CONFIG_IS_ENABLED(CLK)) {
clock_rate = clk_get_rate(&i2c_bus->per_clk);
if (clock_rate <= 0) {
dev_err(bus, "Failed to get i2c clk: %d\n", clock_rate);
@@ -462,7 +462,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
return ret;
}
- if (IS_ENABLED(CONFIG_CLK)) {
+ if (CONFIG_IS_ENABLED(CLK)) {
ret = clk_get_by_name(bus, "per", &i2c_bus->per_clk);
if (ret) {
dev_err(bus, "Failed to get per clk\n");