From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Subject: Re: [PATCH] i2c: at91: Fix driver for SAMA5D2 SoC
Date: Sun, 12 Jan 2025 19:36:54 +0300 [thread overview]
Message-ID: <CAP1tNvQCgE+8+EkAFxChRyKke3EntxXn0Zx1oUAngdYxcMbV8w@mail.gmail.com> (raw)
In-Reply-To: <20250110102840.53331-1-eagle.alexander923@gmail.com>
Hello.
Please discard this patch aside for a while. I'll check it again.
Thanks!
пт, 10 янв. 2025 г. в 13:28, Alexander Shiyan <eagle.alexander923@gmail.com>:
>
> The current driver version does not work for me on SAMA5D2 SOC.
> I2C bus devices probing always returns good state, and as a result all
> addresses 0x01-0x7f are always present.
> After a some digging into the driver, I found that the NACK bit is not
> handled correctly. I also found another SAMA5D2-related patch in the kernel
> tree (1).
> The result is a complex patch for correct I2C bus operation on SAMA5D2 SOC.
>
> [1] https://squing.com/lander/squing.com/?l=linux-i2c&m=156382173106314&w=3&_=%2F%23wXPKnebvZEv31W5L%2FkOlGQ%3D%3D
>
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
> drivers/i2c/busses/i2c-at91.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index dbc5aa4ddf..fb0a922a62 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -113,7 +113,8 @@ static void at91_twi_write(struct at91_twi_dev *dev, unsigned reg, unsigned val)
> static void at91_disable_twi_interrupts(struct at91_twi_dev *dev)
> {
> at91_twi_write(dev, AT91_TWI_IDR,
> - AT91_TWI_TXCOMP | AT91_TWI_RXRDY | AT91_TWI_TXRDY);
> + AT91_TWI_TXCOMP | AT91_TWI_RXRDY |
> + AT91_TWI_TXRDY | AT91_TWI_NACK);
> }
>
> static void at91_init_twi_bus(struct at91_twi_dev *dev)
> @@ -223,8 +224,10 @@ static void at91_twi_write_next_byte(struct at91_twi_dev *dev)
> at91_twi_write(dev, AT91_TWI_THR, *dev->buf);
>
> /* send stop when last byte has been written */
> - if (--dev->buf_len == 0)
> + if (--dev->buf_len == 0) {
> at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP);
> + at91_twi_write(dev, AT91_TWI_IDR, AT91_TWI_TXRDY);
> + }
>
> dev_dbg(dev->dev, "wrote 0x%x, to go %d\n", *dev->buf, dev->buf_len);
>
> @@ -276,7 +279,7 @@ static int at91_twi_wait_completion(struct at91_twi_dev *dev)
>
> dev->transfer_status |= status;
>
> - } while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP));
> + } while (!(status & AT91_TWI_TXCOMP));
>
> at91_disable_twi_interrupts(dev);
>
> @@ -311,11 +314,12 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
> at91_twi_write(dev, AT91_TWI_CR, start_flags);
>
> at91_twi_write(dev, AT91_TWI_IER,
> - AT91_TWI_TXCOMP | AT91_TWI_RXRDY);
> + AT91_TWI_TXCOMP | AT91_TWI_NACK | AT91_TWI_RXRDY);
> } else {
> at91_twi_write_next_byte(dev);
> at91_twi_write(dev, AT91_TWI_IER,
> - AT91_TWI_TXCOMP | AT91_TWI_TXRDY);
> + AT91_TWI_TXCOMP | AT91_TWI_NACK |
> + (dev->buf_len ? AT91_TWI_TXRDY : 0));
> }
>
> ret = at91_twi_wait_completion(dev);
> --
> 2.39.1
>
prev parent reply other threads:[~2025-01-12 16:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 10:28 Alexander Shiyan
2025-01-12 16:36 ` Alexander Shiyan [this message]
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=CAP1tNvQCgE+8+EkAFxChRyKke3EntxXn0Zx1oUAngdYxcMbV8w@mail.gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=barebox@lists.infradead.org \
/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