public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: <Padmarao.Begari@microchip.com>
To: <hs@denx.de>, <u-boot@lists.denx.de>,
	<Conor.Dooley@microchip.com>, <ycliang@andestech.com>
Cc: <Shravan.Chippa@microchip.com>
Subject: Re: [PATCH v1 1/2] i2c: microchip: fix ack sending logic
Date: Fri, 28 Oct 2022 04:44:39 +0000	[thread overview]
Message-ID: <760d0960c01f19c98296e5908045b24e4d27fc96.camel@microchip.com> (raw)
In-Reply-To: <20221026074918.3657055-2-conor.dooley@microchip.com>

> On Wed, 2022-10-26 at 08:49 +0100, Conor Dooley wrote:
> "Master receive mode" was not correctly sending ACKs/NACKs in the
> interrupt handler. Bring the handling of M_SLAR_ACK, M_RX_DATA_ACKED
> &
> M_RX_DATA_NACKED in line with the Linux driver.
> 
> Fixes: 0dc0d1e094 ("i2c: Add Microchip PolarFire SoC I2C driver")
> Reported-by: Shravan Chippa <shravan.chippa@microchip.com>
> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
> ---
>  drivers/i2c/i2c-microchip.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-microchip.c b/drivers/i2c/i2c-
> microchip.c
> index 12f65d0af7..3a27459386 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>
> @@ -265,16 +266,27 @@ 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;
>  		}
>  		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 */
> @@ -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;

Reviewed-by: Padmarao Begari <padmarao.begari@microchip.com>

  reply	other threads:[~2022-10-28  4:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26  7:49 [PATCH v1 0/2] i2c: microchip: misc minor fixes Conor Dooley
2022-10-26  7:49 ` [PATCH v1 1/2] i2c: microchip: fix ack sending logic Conor Dooley
2022-10-28  4:44   ` Padmarao.Begari [this message]
2022-11-14  6:12   ` Heiko Schocher
2022-11-14  9:09   ` Heiko Schocher
2022-10-26  7:49 ` [PATCH v1 2/2] i2c: microchip: fix erroneous late ack send Conor Dooley
2022-10-26  7:54   ` Conor.Dooley
2022-10-28  4:58     ` Padmarao.Begari
2022-10-28  4:43   ` Padmarao.Begari
2022-11-14  6:13   ` Heiko Schocher
2022-11-14  9:09   ` Heiko Schocher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=760d0960c01f19c98296e5908045b24e4d27fc96.camel@microchip.com \
    --to=padmarao.begari@microchip.com \
    --cc=Conor.Dooley@microchip.com \
    --cc=Shravan.Chippa@microchip.com \
    --cc=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox