aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini2022-11-14 07:29:30 -0500
committerTom Rini2022-11-14 07:29:30 -0500
commitfac432652f38724994a99c2613183fc04534a2cd (patch)
treeab7a0cf088b4fbbe73955cab36c5a98eb5c7cf8a
parent0cbeed4f6648e0e4966475e3544280a69ecb59d3 (diff)
parentb0c485fd384b2706717d4c19fa9837c1d785e9e8 (diff)
Merge tag 'for-v2023.01-rc2' of https://source.denx.de/u-boot/custodians/u-boot-i2c
i2c Fixes for v2023.01-rc2 - i2c-gpio: add a missing new line in printed string detected and fixed by Sergei - microchip i2c driver fixes from Conor - fix erroneous late ack send - fix ack sending logic
-rw-r--r--drivers/i2c/i2c-gpio.c2
-rw-r--r--drivers/i2c/i2c-microchip.c25
2 files changed, 19 insertions, 8 deletions
diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index 1aedad5c8ed..4ed9e9e7cdd 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -362,7 +362,7 @@ static int i2c_gpio_of_to_plat(struct udevice *dev)
return 0;
error:
- pr_err("Can't get %s gpios! Error: %d", dev->name, ret);
+ pr_err("Can't get %s gpios! Error: %d\n", dev->name, ret);
return ret;
}
diff --git a/drivers/i2c/i2c-microchip.c b/drivers/i2c/i2c-microchip.c
index 12f65d0af75..d82b80f5355 100644
--- a/drivers/i2c/i2c-microchip.c
+++ b/drivers/i2c/i2c-microchip.c
@@ -2,8 +2,9 @@
/*
* Microchip I2C controller driver
*
- * Copyright (C) 2021 Microchip Technology Inc.
+ * Copyright (C) 2021-2022 Microchip Technology Inc.
* Padmarao Begari <padmarao.begari@microchip.com>
+ * Conor Dooley <conor.dooley@microchip.com>
*/
#include <common.h>
#include <clk.h>
@@ -223,7 +224,7 @@ static void mpfs_i2c_empty_rx(struct mpfs_i2c_bus *bus)
bus->msg_len--;
}
- if (bus->msg_len == 0) {
+ if (bus->msg_len <= 1) {
ctrl = readl(bus->base + MPFS_I2C_CTRL);
ctrl &= ~CTRL_AA;
writel(ctrl, bus->base + MPFS_I2C_CTRL);
@@ -265,10 +266,18 @@ static int mpfs_i2c_service_handler(struct mpfs_i2c_bus *bus)
}
break;
case STATUS_M_SLAR_ACK:
- ctrl = readl(bus->base + MPFS_I2C_CTRL);
- ctrl |= CTRL_AA;
- writel(ctrl, bus->base + MPFS_I2C_CTRL);
- if (bus->msg_len == 0) {
+ if (bus->msg_len > 1u) {
+ ctrl = readl(bus->base + MPFS_I2C_CTRL);
+ ctrl |= CTRL_AA;
+ writel(ctrl, bus->base + MPFS_I2C_CTRL);
+ } else if (bus->msg_len == 1u) {
+ ctrl = readl(bus->base + MPFS_I2C_CTRL);
+ ctrl &= ~CTRL_AA;
+ writel(ctrl, bus->base + MPFS_I2C_CTRL);
+ } else {
+ ctrl = readl(bus->base + MPFS_I2C_CTRL);
+ ctrl |= CTRL_AA;
+ writel(ctrl, bus->base + MPFS_I2C_CTRL);
/* On the last byte to be transmitted, send STOP */
mpfs_i2c_stop(bus);
finish = true;
@@ -276,6 +285,9 @@ static int mpfs_i2c_service_handler(struct mpfs_i2c_bus *bus)
break;
case STATUS_M_RX_DATA_ACKED:
mpfs_i2c_empty_rx(bus);
+ break;
+ case STATUS_M_RX_DATA_NACKED:
+ mpfs_i2c_empty_rx(bus);
if (bus->msg_len == 0) {
/* On the last byte to be transmitted, send STOP */
mpfs_i2c_stop(bus);
@@ -283,7 +295,6 @@ static int mpfs_i2c_service_handler(struct mpfs_i2c_bus *bus)
}
break;
case STATUS_M_TX_DATA_NACK:
- case STATUS_M_RX_DATA_NACKED:
case STATUS_M_SLAR_NACK:
case STATUS_M_SLAW_NACK:
bus->msg_err = -ENXIO;