From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] cmd_i2c: Provide option for bulk 'i2c write' in one transaction
Date: Wed, 28 Jan 2015 07:56:16 +0100 [thread overview]
Message-ID: <54C88810.9010307@denx.de> (raw)
In-Reply-To: <bdd1113471521f477fa114c0e53f2387.squirrel@www.mm-sol.com>
Hello Lubomir,
Am 24.11.2014 17:00, schrieb Lubomir Popov:
> I2C chips do exist that require a write of some multi-byte data to occur in
> a single bus transaction (aka atomic transfer), otherwise either the write
> does not come into effect at all, or normal operation of internal circuitry
> cannot be guaranteed. The current implementation of the 'i2c write' command
> (transfer of multiple bytes from a memory buffer) in fact performs a separate
> transaction for each byte to be written and thus cannot support such types of
> I2C slave devices.
>
> This patch provides an alternative by allowing 'i2c write' to execute the
> write transfer of the given number of bytes in a single bus transaction if
> CONFIG_SYS_I2C_BULK_WRITE is defined in the board header (otherwise the old
> method shall compile).
>
> Signed-off-by: Lubomir Popov <l-popov@ti.com>
> ---
> common/cmd_i2c.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
Could you rebase your patch against current mainline, please?
As we have now DM in i2c subsystem your patch does not apply clean
anymore ... thanks!
bye,
Heiko
>
> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
> index 3a75f94..7116458 100644
> --- a/common/cmd_i2c.c
> +++ b/common/cmd_i2c.c
> @@ -280,10 +280,22 @@ static int do_i2c_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
> return cmd_usage(cmdtp);
>
> /*
> - * Length is the number of objects, not number of bytes.
> + * Length is the number of bytes.
> */
> length = simple_strtoul(argv[4], NULL, 16);
>
> +#if defined(CONFIG_SYS_I2C_BULK_WRITE)
> + /*
> + * Write all bytes in a single I2C transaction. If the target
> + * device is an EEPROM, it is your responsibility to not cross
> + * a page bounady.
> + */
> + if (i2c_write(chip, devaddr, alen, memaddr, length) != 0) {
> + puts("Error writing to the chip.\n");
> + return 1;
> + }
> +#else
> + /* Perform <length> separate write transactions of one byte each */
> while (length-- > 0) {
> if (i2c_write(chip, devaddr++, alen, memaddr++, 1) != 0) {
> puts("Error writing to the chip.\n");
> @@ -296,6 +308,7 @@ static int do_i2c_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
> udelay(11000);
> #endif
> }
> +#endif
> return 0;
> }
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2015-01-28 6:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-24 16:00 [U-Boot] [PATCH] cmd_i2c: Provide option for bulk 'i2c write' in one transaction Lubomir Popov
2014-11-25 21:48 ` Simon Glass
2014-11-26 9:08 ` Lubomir Popov
2014-11-26 19:37 ` [U-Boot] [PATCH V2] " Lubomir Popov
2014-11-26 19:43 ` Simon Glass
2015-01-28 6:56 ` Heiko Schocher [this message]
2015-01-28 8:32 ` [U-Boot] [PATCH] " Lubomir Popov
2015-01-28 8:52 ` Heiko Schocher
2015-01-28 9:00 ` Lubomir Popov
2015-01-28 10:11 ` 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=54C88810.9010307@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/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