mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Tomas Marek <tomas.marek@elrest.cz>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] i2c: add EFI i2c master driver
Date: Mon, 25 Mar 2024 11:39:46 +0100	[thread overview]
Message-ID: <ZgFUcmW8aY-QSlRs@pengutronix.de> (raw)
In-Reply-To: <20240320125538.31679-1-tomas.marek@elrest.cz>

Hi Tomas,

Thanks for the patch. Looks mostly fine, but this needs fixing:

On Wed, Mar 20, 2024 at 01:55:38PM +0100, Tomas Marek wrote:
> +static int efi_i2c_xfer(struct i2c_adapter *adapter,
> +			struct i2c_msg *msg, int nmsgs)
> +{
> +	struct efi_i2c_priv *i2c_priv = adapter_to_efi_i2c_priv(adapter);
> +	int i, ret;
> +
> +	for (i = nmsgs; i > 0; i--, msg++) {
> +		ret = efi_i2c_message_xfer(i2c_priv, msg);
> +		if (ret)
> +			return ret;
> +	}

Each of the messages should start with a (repeated) start bit and only
the last message should be followed by a stop bit. By separating the
full message into segments and pushing each segment into EFI separately
you would instead send a stop bit after each segment, see the comment
above EFI_I2C_REQUEST_PACKET:

///
/// I2C device request
///
/// The EFI_I2C_REQUEST_PACKET describes a single I2C transaction.  The
/// transaction starts with a start bit followed by the first operation
/// in the operation array.  Subsequent operations are separated with
/// repeated start bits and the last operation is followed by a stop bit
/// which concludes the transaction.  Each operation is described by one
/// of the elements in the Operation array.
///

Instead you have to compile all nmsgs into a single EFI_I2C_REQUEST_PACKET
and push it into EFI as a single request.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2024-03-25 10:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 12:55 Tomas Marek
2024-03-25 10:39 ` Sascha Hauer [this message]
2024-03-26  6:08   ` Tomas Marek

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=ZgFUcmW8aY-QSlRs@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=tomas.marek@elrest.cz \
    /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